|

登陆享受更多浏览权限哟~
您需要 登录 才可以下载或查看,没有帐号?入驻经典 
x
<p>题目:学生成绩统计<br/>语言和环境<br/>实现语言<br/>C语言<br/>B、环境要求<br/> Turbo C 或 Turbo C 3.0<br/>要求<br/>请编写一个C语言程序,接收5个学生的信息,获得各自的3门课程中的最高分和最低分,并保存文件中。<br/>程序的功能要求如下:<br/>从键盘输入5个学生的基本信息(学号、姓名)和3门课程的考试成绩。<br/>比较每个学生3门课程考试成绩,获得3门课程中的最高分和最低分。<br/>将每个学生的信息保存在文件StudentScore.txt中,其中包括最高分和最低分。该文件应保存在C程序的同一文件夹中。<br/>算法与数据结构说明<br/>定义一个学生信息结构student(学号、姓名、3门课程的考试成绩、以及这3门课程中的最高分和最低分)。声明一个该结构的数组变量,分别利用函数high()和low()对输入学生的成绩进行比较,获得最高分和最低分,通过WriteFile()函数把每个学生的信息写入文件StudentScore.txt中来保存。<br/>推荐实践步骤<br/>编写main函数<br/>1)声明一个结构数组变量,用来存放5个学生的基本信息。<br/>2)从键盘输入5个学生的基本信息(学号、姓名)和3门课程的考试成绩。请见图1。<br/> <br/>Please input the 1 student information:<br/>Student number<101~999>:101<br/>Student name:Harry<br/>The 1 subject score:100<br/>The 2 subject score:99<br/>The 3 subject score:89<br/>Please input the 2 student information:<br/>Student number<101~999>: <br/> 输入数据过程中,要求实现对学生信息有效性验证。具体要求如下:<br/>学生学号由3位数字组成。如果输入的学号大于999 或者小于101,程序应该给出错误提示信息“The number is wrong.Please repeat now.”,要求重新输入。<br/>每门课程的考试成绩的取值范围是:0到100 之内的整数或带一位小数的值。若不在这个范围之内,屏幕应该给出提示信息“The score is worng,Please reqeat now.”。详见图2。<br/> <br/>Please input the 1 student information:<br/>Student number<101~999>:10<br/>The number is worng.Pease repeat now.<br/>Student number<101~999>:101<br/>Student name:Harry<br/>The 1 subject score<0——100>:99.5<br/>The 2 subject score<0——100>:102<br/>The score is wrong.Please repeat now.<br/>The 2 subject score<0——100>:100<br/>The 3 subject score<0——100>:-25<br/>The score is wrong.Please repeat now.<br/>The 3 subject score<0——100>:69.5<br/>Please input the 2 student information:<br/>Student number (100——99): </p><p> (3 ) 调用函数high() 和 low() 分别对输入学生的成绩进行比较,获得最高分和最低分。<br/> (4 )输出这5个学生的基本信息和3门课程的考试成绩,以及其中得最高分和最低分。<br/>输出结果清参加图3.<br/> <br/>The 1 Student information:<br/> Student – no:101<br/> Student –name:Harry<br/> The 1 subject :100.0<br/> The 2 subject:99.0<br/> The 3 subject:89.0</p><p><br/> The highest score is 100.0<br/> The lowest score is 89.0<br/>The 2 Student information:<br/> Student – no:101<br/> Student –name:Harry<br/> The 1 subject :99.5<br/> The 2 subject:100.0<br/> The 3 subject:69.5</p><p><br/> The highest score is 100.0<br/> The lowest score is 69.5<br/>The 3 Student information:<br/> Student – no:102<br/> Student –name:john<br/> The 1 subject :89.0<br/> The 2 subject:92.0<br/> The 3 subject:94.0</p><p><br/> The highest score is 92.0<br/> The lowest score is 89.0 <br/> (5) 通过WriteFile()函数把每个学生的信息写入文件StudentScore.txt中来保存。<br/>(6) 根据函数的返回值判断文件操作是否正常,并在屏幕上显示出相应得提示信息。<br/>要求:<br/>屏幕输出请参照图4。<br/> <br/>The 5 Student information:<br/> Student – no:104<br/> Student –name:hit<br/> The 1 subject : 90.0<br/> The 2 subject:92.0<br/> The 3 subject:88.0</p><p><br/> The highest score is 92.0<br/> The lowest score is 88.0<br/>The file successed.<br/>Prease any key to continue. <br/>2.编写high()子函数<br/>参数:<br/> 存放了学生3门课程的考试成绩的数组,float 类型。<br/>返回值:<br/> Float 类型,返回最高分数。<br/>功能:<br/> 利用循环对存放了学生3 门课程的考试成绩的数组参数进行大小比较,返回3门课程的最高分。<br/>编写low()子函数<br/>参数:<br/> 存放了学生3门课程的考试成绩的数组,float 类型。<br/>返回值:<br/> Float 类型,返回最低分数。<br/>功能:<br/> 利用循环对存放了学生3 门课程的考试成绩的数组参数进行大小比较,返回3门课程的最低分。<br/>编写writefile()子函数<br/>参数:<br/>存放5 个学生信息的结构数组,struct student * stu.<br/>返回值:<br/> 整型数。-1表示文件操作失败;0表示文件操作正常。<br/>功能:<br/>1) 以写文本方式创建并打开文件。如有错误,2) 返回-1。<br/>3) 通过循环,4) 把每个字符串写入文件“studentScore.txt”中。<br/>5) 关闭文件。<br/>6) 返回0。<br/>使用记事本打开StudentScore.txt文件,文件中保存的********如下图所示:<br/> <br/>101 Harry 100.0 99.0 89.0 100.0 89.0<br/>102 Mary 99.5 100.0 69.5 100.0 69.5 <br/>103 John 89.5 92.0 94.5 94.5 89.0<br/>104 Macho 98.0 93.0 83.4 98.0 83.4<br/>105 Hit 90.0 92.0 88.0 92.0 88.0 </p><p> </p> |
|