From b0e78d63329908ef497457b110b863d8c0de881e Mon Sep 17 00:00:00 2001 From: pecp45i32 Date: Sat, 23 Nov 2024 06:53:11 +0800 Subject: [PATCH] ADD file via upload --- step2.cpp | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 step2.cpp diff --git a/step2.cpp b/step2.cpp new file mode 100644 index 0000000..ea76091 --- /dev/null +++ b/step2.cpp @@ -0,0 +1,85 @@ +#include + +#define COL 4 + +int studentMember = 0; +void inputStudentInformation(double store[][COL]) +{ + double* p; + int i = 0, j = 0; + while (1) { + p = &store[i][j]; + double temp; + scanf("%lf", &temp); + *p = temp; + j++; + if (j == COL) { + printf("One student's information has been, input 0 or 1 to quit or continue.\n"); + int ch; + scanf("%d", &ch); + if (ch == 0) { break; } + else if (ch == 1) + { + j = 0; + i++; + studentMember++; + } + else { + printf("WRONG INPUT,aoto quit\n"); + break; + } + } + } +} + +double sumScore(double store[][COL], int n) { + double sum = 0; + for (int i = 1; i < COL; i++) { + sum += store[n][i]; + } + return sum; +} + + +void printStudentOriginalScore(double store[][COL]) +{ + for (int i = 0; i <= studentMember; i++) { + printf("%5d %.1f %.1f %.1f %.1f\n", (int)store[i][0], store[i][1], store[i][2], store[i][3], sumScore(store, i)); + } +} + +void manage() +{ + printf(" 1.Input\n"); + printf(" 2.Output\n"); + printf(" 3.Order\n"); + printf(" 4.Quit\n"); + char keywords; + keywords = getchar(); + switch (keywords) { + case 'i': + printf("You are trying to Input info\n"); + break; + case 'o': + printf("You are trying to Output info\n"); + break; + case 'm': + printf("You are trying to Make things ordered\n"); + break; + case 'q': + printf("You are about to Quit\n"); + break; + default: + printf("Wrong input\n"); + break; + } +} + +int main() +{ + double* p, storeInformation[100][COL]; + inputStudentInformation(storeInformation); + printStudentOriginalScore(storeInformation); + //manage(); + return 0; +} \ No newline at end of file