diff --git a/step 3.cpp b/step 3.cpp new file mode 100644 index 0000000..83f5ef3 --- /dev/null +++ b/step 3.cpp @@ -0,0 +1,91 @@ +#include + +#define COL 4 +#define GRADEBINGIN 1 + +int studentMember = 0; +double storeInformation[100][COL]; + +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 = GRADEBINGIN; 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 printstep2(double store[][COL]) { + for (int i = 0; i <= studentMember; i++) { + printf("%5d,%.1f,%.1f\n", (int)storeInformation[i][0], sumScore(storeInformation, i), sumScore(storeInformation, i) / 3); + } +} + +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("Please input info of the three students\n"); + inputStudentInformation(storeInformation); + 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() +{ + manage(); + printstep2(storeInformation); + return 0; +} \ No newline at end of file