1 条题解

  • 0
    @ 2026-7-28 14:49:55

    三科成绩单 题解

    思路

    本题重点是结构体的定义、创建对象以及使用 . 访问成员。读入后直接累加三个成绩即可。

    参考代码

    #include <bits/stdc++.h>
    using namespace std;
    
    struct Student {
        string name;
        int chinese;
        int math;
        int english;
    };
    
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    
        Student s;
        cin >> s.name >> s.chinese >> s.math >> s.english;
        int total = s.chinese + s.math + s.english;
        cout << s.name << ' ' << total << '\n';
        return 0;
    }
    

    信息

    ID
    5083
    时间
    1000ms
    内存
    256MiB
    难度
    1
    标签
    递交数
    17
    已通过
    6
    上传者