diff --git a/README.md b/README.md index bf9dd8f..1f88bc2 100644 --- a/README.md +++ b/README.md @@ -479,7 +479,12 @@ Step 4:输出总成绩和平均分 ![输出n个学生的学号,姓名以及m门课程的成绩](-WritetoFile.svg) #### ReadfromFile +Step 1:从文件中读取学生人数和课门数 +Step 2:利用循环for输入学生学号和姓名 +Step 3:利用二次循环输入学生成绩 +Step 4:输入学生总成绩和平均分 +![从文件中读取学生的学号,姓名及成绩等信息写入结构体](ReadfromFile.svg) #### exit ## 代码实现 diff --git a/ReadfromFile.svg b/ReadfromFile.svg new file mode 100644 index 0000000..4a66a2d --- /dev/null +++ b/ReadfromFile.svg @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + ReadfromFile + + + + + + End + + + + + + + + + + + + + + + + + Integer i + + + + + + + + Integer j + + + + + + + + + + + + + (fp = fopen("student.txt", + "r")) == NULL + + + + + + Output "Failure to open + score.txt!\n" + + + + + + + True + + + False + + + + + + Input fp, "%d\t%d", n, m + + + + + + + + + + + + + + + + + + Input fp, "%10ld", &stu[i].num + + + + + + Input fp, "%10s", stu[i].name + + + + + + + + + + + Input fp, "%10f", &stu[i].score + [j] + + + + + + j = 0 to m-1 + + + + Next + + + Done + + + + + + Input fp, "%10f%10f", &stu[i]. + sum, &stu[i].aver + + + + + + + i = 0 to n-1 + + + + Next + + + Done + + + + +