救命!样例过了但不对
2023-12-24 11:23:33
发布于:辽宁
128阅读
0回复
0点赞
#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;
}
全部评论 8
e
都这样写了可以不用结构体了吧#include<iostream> using namespace std; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ string name; double fen; int age; cin>>name>>fen>>age; cout<<name<<' '; printf("%.1f %d\n",fen,age); } return 0; }2026-04-14 来自 天津
1?和这个有关系吗
2026-04-19 来自 浙江
0还有 printf 和 cout 混用
2026-04-19 来自 浙江
0怎么了?
2026-04-19 来自 天津
0
保留一位小数
要用printf输出分数2026-02-11 来自 湖北
11.分数要用printf,来保留一位小数 2.数组大小设为100即可
2025-11-26 来自 浙江
1分数要用printf保留一位小数哦,亲~
2024-01-06 来自 北京
1请看题
2026-04-19 来自 湖北
0请说出里面有多少知识点
#include<array> #include<cstdio> #include<string> #include<iostream> constexpr unsigned int N=static_cast<unsigned int>(1e2+10); class Node{ private: std::string _name; double _score; unsigned int _age; public: Node()=default; Node(const std::string& name,double score,unsigned int age): _name(name),_score(score),_age(age){} Node(const Node& other): _name(other._name),_score(other._score),_age(other._age){} Node(Node&& other): _name(other._name),_score(other._score),_age(other._age){} Node& operator=(const Node& other){ _name=other._name; _score=other._score; _age=other._age; return *this; } Node& operator=(Node&& other){ _name=other._name; _score=other._score; _age=other._age; return *this; } ~Node()=default; std::string& name(void){return _name;} double& score(void){return _score;} unsigned int& age(void){return _age;} }; std::basic_istream<char>& operator>>(std::basic_istream<char>& is,Node& node){ is>>node.name(); is>>node.score(); is>>node.age(); return is; } std::basic_ostream<char>& operator<<(std::basic_ostream<char>& os,Node node){ os<<node.name()<<' '; std::printf("%.1f ",node.score()); os<<node.age()<<'\n'; return os; } auto main([[maybe_unused]] int argc,[[maybe_unused]] char* argv[])->int{ std::cin.tie(nullptr); std::array<Node,N> nodes{}; int total=0; std::cin>>total; for(unsigned int at=1;at<=total;at++) std::cin>>nodes.at(at); for(unsigned int at=1;at<=total;at++) std::cout<<nodes.at(at); }2026-04-14 来自 香港
0知识点:如何使用 AI
2026-04-19 来自 浙江
0
#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








































有帮助,赞一个