编写 一个程序, 输入N个学生数据,包括学号,姓名,成绩,要求输出这些学生数据并计算平均分
#include<bits/stdc++.h>
using namespace std;
class Student
{
private:
int no;
char name[10];
int deg;
static int sum;
static int num;
public:
void setdata(int n,char na[],int d)
{
no=n;
strcpy(name,na);
deg=d;
sum+=d;
num++;
}
static double avg()
{
return sum/num;
}
void disp()
{
cout<<no<<name<<deg<<endl;
}
};
int Student::sum=0;
int Student::num=0;
int main()
{
int n;
cin>>n;
Student stu1,stu2;
stu1.setdata(201,"s",55);
stu2.setdata(203,"sss",88);
stu1.disp();
stu2.disp();
int s = Student::avg();
cout<<s<<endl;
}