From 3f5fdb39a4ce851218c51db6b7a0245716dbee83 Mon Sep 17 00:00:00 2001 From: zhangyu <387881603@qq.com> Date: Tue, 25 Apr 2023 17:07:44 +0800 Subject: [PATCH 1/2] ZY-ReadfromFile --- README.md | 5 ++ ReadfromFile.svg | 157 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 ReadfromFile.svg diff --git a/README.md b/README.md index 4ad36b8..310ae57 100644 --- a/README.md +++ b/README.md @@ -457,7 +457,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..948887e --- /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, "%10ld", &stu[i].num + + + + + + + + + + + + + + + + + + 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 + + + + + From be7204dee6562b4c18fa24699c9ff562318bf7e9 Mon Sep 17 00:00:00 2001 From: zhangyu <387881603@qq.com> Date: Tue, 25 Apr 2023 19:15:26 +0800 Subject: [PATCH 2/2] ZY-ReadfromFile --- README.md | 2 +- ReadfromFile.svg | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 310ae57..550810c 100644 --- a/README.md +++ b/README.md @@ -462,7 +462,7 @@ Step 2:利用循环for输入学生学号和姓名 Step 3:利用二次循环输入学生成绩 Step 4:输入学生总成绩和平均分 -![从文件中读取学生学号,姓名及成绩等信息写入结构体](ReadfromFile.svg) +![从文件中读取学生的学号,姓名及成绩等信息写入结构体](ReadfromFile.svg) #### exit ## 代码实现 diff --git a/ReadfromFile.svg b/ReadfromFile.svg index 948887e..4a66a2d 100644 --- a/ReadfromFile.svg +++ b/ReadfromFile.svg @@ -77,9 +77,9 @@ - + - Input fp, "%10ld", &stu[i].num + Input fp, "%d\t%d", n, m