全部评论 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
  • 保留一位小数
    要用printf输出分数

    2026-02-11 来自 湖北

    1
  • 1.分数要用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
  • #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 来自 浙江

    0
  • printf("%.1lf",x[i].fen);
    

    2024-07-30 来自 浙江

    0
暂无数据

提交答案之后,这里将显示提交结果~

首页