哈尔滨工业大学C语言MOOC第12周编程题在线测试_第1页
哈尔滨工业大学C语言MOOC第12周编程题在线测试_第2页
哈尔滨工业大学C语言MOOC第12周编程题在线测试_第3页
哈尔滨工业大学C语言MOOC第12周编程题在线测试_第4页
哈尔滨工业大学C语言MOOC第12周编程题在线测试_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

第12周编程题在线测试1计算时间差V2.0(4分)题目内容:用结构体定义时钟类型,编程从键盘任意输入两个时间(例如4时55分和1时25分),计算并输出这两个时间之间的间隔。要求不输出时间差的负号。结构体类型定义如下:typedef struct clock int hour; int minute; int second; CLOCK;函数原型: CLOCK CalculateTime(CLOCK t1, CLOCK t2);函数功能:计算并返回两个时间t1和t2之间的差程序运行结果示例1:Input time one:(hour,minute):4,55Input time two: (hour,minute):1,253hour,30minute程序运行结果示例2:Input time one:(hour,minute):1,33Input time two: (hour,minute):5,213hour,48minute输入提示: Input time one:(hour,minute): Input time two: (hour,minute):输入格式: %d,%d输出格式:%dhour,%dminuten代码:#include #include #include #include typedef struct clock int hour; int minute; int second; CLOCK;CLOCK CalculateTime(CLOCK t1, CLOCK t2);int main() CLOCK c1; CLOCK c2; printf(Input time one:(hour,minute):); scanf(%d,%d, & c1.hour, & c1.minute); printf(Input time two: (hour,minute):); scanf(%d,%d, & c2.hour, & c2.minute); CLOCK c=CalculateTime(c1,c2); printf(%dhour,%dminuten,c.hour,c.minute ); return 0;CLOCK CalculateTime(CLOCK t1, CLOCK t2) long start=t1.hour*60+t1.minute; long end=t2.hour*60+t2.minute; long delta=abs (end-start); CLOCK c= delta/60,delta%60; return c;2奖学金发放(4分)题目内容:某校的惯例是在每学期的期末考试之后发放奖学金。发放的奖学金共有五种,每项奖学金获取的条件分别如下:1) 院士奖学金:期末平均成绩高于80分(80),并且在本学期内发表1篇或1篇以上论文的学生每人均可获得8000元;2) 五四奖学金:期末平均成绩高于85分(85),并且班级评议成绩高于80分(80)的学生每人均可获得4000元;3) 成绩优秀奖:期末平均成绩高于90分(90)的学生每人均可获得2000元;4) 西部奖学金:期末平均成绩高于85分(85)的西部省份学生每人均可获得1000元;5) 班级贡献奖:班级评议成绩高于80分(80)的学生干部每人均可获得850元;只要符合上述条件就可获得相应的奖项,每项奖学金的获奖人数没有限制,每名学生也可以同时获得多项奖学金。例如姚明的期末平均成绩是87分,班级评议成绩82分,同时他还是一位学生干部,那么他可以同时获得五四奖学金和班级贡献奖,奖金总数是4850元。现在给出若干学生的相关数据(假设总有同学能满足获得奖学金的条件),请编程计算哪些同学获得的奖金总数最高。结构体类型定义如下:typedef struct winners char name20; int finalScore; int classScore; char work; char west; int paper; int scholarship; WIN;函数原型:void Addup(WIN stu, int n);函数原型:int FindMax(WIN student, int n);程序运行结果示例:Input n:4Input name:YaoMingInput final score:87Input class score:82Class cadre or not?(Y/N):YStudents from the West or not?(Y/N):NInput the number of published papers:0name:YaoMing,scholarship:4850Input name:ChenRuiyiInput final score:88Input class score:78Class cadre or not?(Y/N):NStudents from the West or not?(Y/N):YInput the number of published papers:1name:ChenRuiyi,scholarship:9000Input name:LiXinInput final score:92Input class score:88Class cadre or not?(Y/N):NStudents from the West or not?(Y/N):NInput the number of published papers:0name:LiXin,scholarship:6000Input name:ZhangQinInput final score:83Input class score:87Class cadre or not?(Y/N):YStudents from the West or not?(Y/N):NInput the number of published papers:1name:ZhangQin,scholarship:8850ChenRuiyi get the highest scholarship 9000输入学生人数提示:Input n:输入学生姓名提示:Input name:输入学生期末平均成绩提示:Input final score:输入学生班级评议成绩提示:Input class score:输入是否为学生干部提示:Class cadre or not?(Y/N):输入是否为西部学生提示:Students from the West or not?(Y/N):输入发表文章数量提示:Input the number of published papers:输入格式: 输入学生人数:%d 输入学生姓名:%s 输入学生成绩:%d 输入是否为学生干部: %c (注意:%c前面有一个空格) 输入是否为西部学生: %c (注意:%c前面有一个空格) 输入发表文章数量: %d输出格式: 输出学生获得的奖学金: name:%s,scholarship:%dn 输出获得奖学金总数最高的学生:%s get the highest scholarship %dn代码:#includetypedef struct winnerschar name20;int finalScore;int classScore;char work;char west;int paper;int scholarship; WIN;main()int i,count=0,n,s; WIN stu100; printf(Input n:); scanf(%d,&n); s = n; while (n-) stucount.scholarship = 0; printf(Input name:); scanf(%s, &); printf(Input final score:); scanf(%d, &stucount.finalScore); printf(Input class score:); scanf(%d, &stucount.classScore); printf(Class cadre or not?(Y/N):); scanf( %c, &stucount.work); printf(Students from the West or not?(Y/N):); scanf( %c, &stucount.west); printf(Input the number of published papers:); scanf(%d, &stucount.paper); if (stucount.finalScore 90) stucount.scholarship += 2000; if (stucount.finalScore 85& stucount.classScore80) stucount.scholarship += 4000; if(stucount.classScore80) if (stucount.work != 78) stucount.scholarship += 850; if (stucount.finalScore85) if (stucount.west != 78) stucount.scholarship += 1000; if (stucount.finalScore 80 & stucount.paper) stucount.scholarship += 8000; printf(name:%s,scholarship:%dn, , stucount.scholarship); count+; int max; count = 0; max = stu0.scholarship; for (i = 0; i s; i+) if (max stui.scholarship) max = stui.scholarship; count = i; printf(%s get the highest scholarship %dn, , max);3评选最牛群主v1.0(4分)题目内容:现在要评选最牛群主,已知有3名最牛群主的候选人(分别是tom,jack和rose),有不超过1000人参与投票,最后要通过投票评选出一名最牛群主,从键盘输入每位参与投票的人的投票结果,即其投票的候选人的名字,请你编程统计并输出每位候选人的得票数,以及得票数最多的候选人的名字。候选人的名字中间不允许出现空格,并且必须小写。若候选人名字输入错误,则按废票处理。程序运行结果示例1:Input the number of electorates:8Input vote 1:tomInput vote 2:jackInput vote 3:roseInput vote 4:tomInput vote 5:roseInput vote 6:roseInput vote 7:jackInput vote 8:roseElection results:tom:2jack:2rose:4rose wins程序运行结果示例2:Input the number of electorates:5Input vote 1:tomInput vote 2:maryInput vote 3:roseInput vote 4:jackInput vote 5:tomElection results:tom:2jack:1rose:1tom wins提示输入候选人数量:Input the number of electorates:提示输入候选人: Input vote %d:输入格式: 输入候选人数量:%d 输入候选人姓名:%s 输出格式: 输出候选人得票数:%s:%dn 输出票数最多的候选人姓名:%s winsn输出评选结果提示信息:Election results:n代码:#includeint main()int n, i, vote1 = 0, vote2 = 0, vote3 = 0;char name10;printf(Input the number of electorates:);scanf(%d, &n);for (i = 0; i vote2&vote1vote3)printf(%s winsn, tom, vote1);else if (vote2vote1&vote2vote3)printf(%s winsn, jack, vote2);elseprintf(%s winsn, rose, vote3);return 0;4.星期判断(4分)题目内容:请输入星期几的第一个字母(不区分大小写)来判断一下是星期几,如果第一个字母一样,则继续判断第二个字母(小写),否则输出“data error”。程序运行结果示例1:please input the first letter of someday:Splease input second letter:usunday程序运行结果示例2:please input the first letter of someday:Ffriday程序运行结果示例2:please input the first letter of someday:hdata error第一个字母的输入提示信息:please input the first letter of someday:n第二个字母的输入提示信息:please input second letter:n用户输入错误提示信息:data errorn输入格式: %c (注意:%c前面

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论