#include <iostream>
using namespace std;
struct student
{
char name[20];
int num;
float score;
char grade;
};
void func(student *sp)
{
student *t;
t=sp;
for(;sp<t+3;sp++)
{
if(sp->score>=80&&sp->score<=100)
sp->grade='A';
else if(sp->score>=60&&sp->score<=80)
sp->grade='B';
else if(sp->score>=0&&sp->score<=60)
sp->grade='C';
}
}
int main() {
student stu[3],*p;
for(p=stu;p<stu+3;p++)
{
cout<<"输入三个学生信息:"<<endl;
cout<<"姓名:"<<endl; cin.get(p->name,20);
cout<<"学号:"<<endl; cin>>p->num;
cout<<"分数:"<<endl; cin>>p->score;
cin.get();
}
p=stu;
func(p);
cout<<"---------------------"<<endl;
for(p=stu;p<stu+3;p++)
{
cout<<"学号"<<p->num<<"的同学 "<<p->name<<"等级是 "<<p->grade<<endl;
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: