四个课程设计的程序.doc

  1. 1、本文档共10页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
四个课程设计的程序

四个课程设计的程序 ---------------------------------------------------------------------1 题目: 第21题(必做题) 设有以下结构体类型: Struct student { Char num[5],name[20]; Int s[4]; Double ave; } (1) 编写函数把10名学生的学号,姓名,四项成绩以及平均分放在一个结构体数组中,学生的学号,姓名和四项成绩由键盘输入,然后计算出平均分放在结构体对应的域中。 (2) 编写函数writerec输出学生的记录。 (3) 编写通过学号或学生的姓名查找学生的记录的函数findrec。 (4) Main函数调用readrec函数和writerec函数,以及findrec函数,实现全部功能。 程序: #include iostream using namespace std; struct Student {int number; char name[20]; int score[4]; double ave; } stu[10]; int main() { void readrec(); void findrec(); void writerec(); readrec( ); writerec( ); findrec ( ); return 0;} void readrec() {for(int m=0;m10;m++) {cout[m+1] Plesase input the number,name and the scores: ; cinstu[m].numberstu[m].namestu[m].score[0]stu[m].score[1]stu[m].score[2]stu[m].score[3]; stu[m].ave=(stu[m].score[0]+stu[m].score[1]+stu[m].score[2]+stu[m].score[3])/4.0; }} void writerec() {coutThe record is:endl; for(int m=0;m10;m++) {coutstu[m].number\tstu[m].name\tThe scores are: stu[m].score[0]\t; coutstu[m].score[1]\tstu[m].score[2]\tstu[m].score[3]\tThe average score is:stu[m].aveendl; }} void findrec( ) {int number; char name[20]; coutPlease input the number and name you want to search: ; cinnumbername; coutthe result is: endl; for(int m=0;m10;m++) { if(number==stu[m].number) {coutstu[m].number\tstu[m].name\tThe scores are: stu[m].score[0]\tstu[m].score[1]; cout\tstu[m].score[2]\tstu[m].score[3]\tThe average score is: stu[m].aveendl; break; }; if(name==stu[m].name) { coutstu[m].number\tstu[m].name\tThe scores are: stu[m].score[0]\tstu[m].score[1]; cout\tstu[m].score[2]\tstu[m].score[3]\tThe average score is: stu[m].aveendl; break;}; } } -------------------------------------------------02 题目:9、插入后自动排序(掌握用穷举法进行比较、交换) 把一个整数插入到按由小到大排列的数列中,插入后仍然保持由小到大的顺序排列。 要求:用数据指针。 #include iostream using namespace std; int main() {void select_sort(int *p,int n)

文档评论(0)

jgx3536 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:6111134150000003

1亿VIP精品文档

相关文档