正在加载图片...
record student; record getrecordo record temp; in>>temp. name>>temp. math>>temp. eng; temp. ave=(temp. math+temp. eng)/2.0 return temp;/返回结构体值 void show(record s) cout<<s name<<'it<<s math<< \t<<seng<<'t<<s ave<<endl; void mainO int 1; cou←<"请输入姓名,数学成绩,英语成绩<<end; for F0; K<N; i++) studenti=getrecordo cout<<"姓名"<<"t<<"数学"<<"'<<"英语"<<"'<<"平均分"<<endl for(i=0;<N;i++) show(studentiD 运行时当你输入 Sun ZhaI 6076 O 9 程序运行结果如下 姓名数学英语平均分 91 84.5 68 91.5 65 5生成有N学生记录的单链表 #includesiostream. h> #define n 4 struct student∥定义链表结点类型 char name 16 float score} ; record student[N]; record getrecord() { record temp; cin>>temp.name>>temp.math>>temp.eng; temp.ave=(temp.math+temp.eng)/2.0; return temp; //返回结构体值 } void show(record s) { cout<<s.name<<'\t'<<s.math<<'\t'<<s.eng<<'\t'<<s.ave<<endl; } void main() { int i; cout<<"请输入姓名,数学成绩,英语成绩"<<endl; for (i=0;i<N;i++) student[i]=getrecord(); cout<<"姓名"<<'\t'<<"数学"<<'\t'<<"英语"<<'\t'<<"平均分"<<endl; for(i=0;i<N;i++) show(student[i]); } 运行时当你输入: Sun 78 91 Zhang 60 76 Qian 88 95 Fang 60 70 程序运行结果如下: 姓名 数学 英语 平均分 Sun 78 91 84.5 Zhang 60 76 68 Qian 88 95 91.5 Fang 60 70 65 5 生成有 N 学生记录的单链表 #include<iostream.h> #define N 4 struct student //定义链表结点类型 { int no; char name[16]; float score;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有