c++结构体应用之成绩管理
发布网友
发布时间:2024-03-31 00:12
我来回答
共2个回答
热心网友
时间:2024-04-11 03:10
#include<iostream>
using namespace std;
struct student
{
int num;
char name[20];
unsigned short int english;
unsigned short int lisanshuxue;
unsigned short int shujujiegou;
unsigned short int OOP;
float avre;
};
int main()
{
int count,b;
struct student student[100];
entry:
cout<<"请输入要录入成绩的人数:";
cin>>count;
if(count>100||count<=0)
{
cout<<"输入出错"<<endl;
goto entry;
}
else
{
for(b=1;b<=count;b++)
{
cout<<"输入学号";
cin>>student[b].num;
cout<<"输入姓名";
cin>>student[b].name;
cout<<"请输入大学英语成绩";
cin>>student[b].english;
cout<<"请输入离散数学成绩";
cin>>student[b].lisanshuxue;
cout<<"请输入数据结构成绩";
cin>>student[b].shujujiegou;
cout<<"请输入OOP成绩";
cin>>student[b].OOP;
student[b].avre=(student[b].english+student[b].shujujiegou+student[b].lisanshuxue+student[b].OOP)/4.0;
}
for(int i=1;i<b;i++)
{
cout<<"学号:"<<student[i].num<<endl<<"大学英语"<<student[i].english<<endl<<"离散数学"<<student[i].lisanshuxue<<endl<<"数据结构"<<student[i].shujujiegou<<endl<<"OOP"<<student[i].OOP<<endl<<"平均成绩"<<student[i].avre<<endl;
}
system("Pause");
}
}
刚好看到有这代码 找给你了 第一题·
热心网友
时间:2024-04-11 03:09
#include<iostream>
using namespace std;
struct student
{
int num;
char name[20];
unsigned short int english;
unsigned short int lisanshuxue;
unsigned short int shujujiegou;
unsigned short int OOP;
float avre;
};
int main()
{
int count,b;
struct student student[100];
entry:
cout<<"请输入要录入成绩的人数:";
cin>>count;
if(count>100||count<=0)
{
cout<<"输入出错"<<endl;
goto entry;
}
else
{
for(b=1;b<=count;b++)
{
cout<<"输入学号";
cin>>student[b].num;
cout<<"输入姓名";
cin>>student[b].name;
cout<<"请输入大学英语成绩";
cin>>student[b].english;
cout<<"请输入离散数学成绩";
cin>>student[b].lisanshuxue;
cout<<"请输入数据结构成绩";
cin>>student[b].shujujiegou;
cout<<"请输入OOP成绩";
cin>>student[b].OOP;
student[b].avre=(student[b].english+student[b].shujujiegou+student[b].lisanshuxue+student[b].OOP)/4.0;
}
for(int i=1;i<b;i++)
{
cout<<"学号:"<<student[i].num<<endl<<"大学英语"<<student[i].english<<endl<<"离散数学"<<student[i].lisanshuxue<<endl<<"数据结构"<<student[i].shujujiegou<<endl<<"OOP"<<student[i].OOP<<endl<<"平均成绩"<<student[i].avre<<endl;
}
system("Pause");
}
}