是不是不能用 `time` 这个变量名?
by cachejtt @ 2022-12-16 11:50:51
我试一下呢
by wkl20110514 @ 2022-12-16 11:52:43
不能用time作变量名
by Interstice @ 2022-12-16 11:54:20
c++有time这个函数,不能用其作变量名
by ZQIN_P @ 2022-12-16 11:55:42
知道了,谢谢,已经可以了
by wkl20110514 @ 2022-12-16 11:56:12
注意,输出的应该是每个人的编号+平均时间
所以建议把
```c
printf("%0.0lf ",a[i].num);
```
变为
```c
printf("%d ",a[i].number);
```
点个赞呗~
by henglizuo @ 2023-04-03 20:39:48
@[Fansitong](/user/983098) 全代码:
```cpp
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
struct people{
double num;
int number;
}a[1001];
bool cmp(people x,people y){
return x.num<y.num;
}
double t=0;
int n;
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%lf",&a[i].num);
a[i].number=i+1;
}
sort(a,a+n,cmp);
for(int i=0;i<n;i++){
printf("%d ",a[i].number);
for(int j=0;j<i;j++) t+=a[j].num;
}
printf("\n%0.2lf",t/n);
return 0;
}
```
by henglizuo @ 2023-04-03 20:41:12