#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <cstdlib>
using namespace std;
class Student {
private:
char name[20];
char num[20];
char k;
int cal,y1,y2,y3,y4,age;
public:
void input(){
cin.get(name,20,',');
cin>>k>>age>>k;
cin.get(num,20,',');
cin>>k>>y1>>k>>y2>>k>>y3>>k>>y4;
}
void calculate(){
cal=(y1+y2+y3+y4)/4;
}
void output(){
cout<<name<<","<<age<<","<<num<<","<<cal;
}
};
int main() {
Student student; // 定义类的对象
student.input(); // 输入数据
student.calculate(); // 计算平均成绩
student.output(); // 输出数据
}
一个小的关于学生成绩的类
最新推荐文章于 2022-10-13 15:53:31 发布