?? 炒飯問題1.cpp
字號:
#include<iostream>
using namespace std;
#include<algorithm>
int time(int *a,int n)
{
int i=1,j=0,b[1000];
int t=a[0];
b[0]=a[0];
while(i<n)
{
b[i]=a[i]+b[i-1];
t=b[i]+t;
i++;
}
return t;
}
main()
{
int i,n;
int a[1000];
while((scanf("%d",&n))!=EOF)
{
for(i=0;i<n;i++)
scanf("%d",&a[i]);
sort(a,a+n);
printf("%d\n",time(a,n));
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -