救命!样例过了但不对
原题链接:7863.【结构体】结构体数组的遍历2023-12-24 11:23:33
发布于:辽宁
#include <iostream>
using namespace std;
int n;
struct Node{
string name;
double fen;
int age;
}x[10005];
int main(){
int n;
cin >> n;
for(int i=0;i<n;i++){
cin >> x[i].name >> x[i].fen >> x[i].age;
cout << x[i].name << " " << x[i].fen << " " << x[i].age << endl;
}
return 0;
}
全部评论 3
#include<bits/stdc++.h> using namespace std; struct student{ string name; double sc; int age; }a[10010]; int main(){ int n; cin >> n; for (int i = 0; i < n; i++){ cin >> a[i].name >> a[i].sc >> a[i].age; } for (int i = 0; i < n; i++){ cout << a[i].name << " " ; printf("%.1f ",a[i].sc); cout << a[i].age << endl; } return 0; }
2024-10-27 来自 浙江
0printf("%.1lf",x[i].fen);
2024-07-30 来自 浙江
0分数要用printf保留一位小数哦,亲~
2024-01-06 来自 北京
0
有帮助,赞一个