diff --git a/step5.cpp b/step5.cpp new file mode 100644 index 0000000..4b35eb1 --- /dev/null +++ b/step5.cpp @@ -0,0 +1,101 @@ +#include +#include + +int studentMember = 0; + +typedef struct storeInformation +{ + char stus[100]; + int classes; + char names[100]; + double mathGrade; + double physicsGrade; + double englishGrade; + int boolNew; +}stu; + +stu studentInformation[100]; + +void inputStudentInformation(int n) +{ + for (int i = 0; i < n; i++) { + scanf("%s", studentInformation[i].stus); + scanf("%d", &studentInformation[i].classes); + scanf("%s", studentInformation[i].names); + scanf("%lf", &studentInformation[i].mathGrade); + scanf("%lf", &studentInformation[i].physicsGrade); + scanf("%lf", &studentInformation[i].englishGrade); + studentMember++; + studentInformation[i].boolNew = 0; + printf("One student has been input!\n"); + } +} + +void insertedNew() { + int i = studentMember; + scanf("%s", studentInformation[i].stus); + scanf("%d", &studentInformation[i].classes); + scanf("%s", studentInformation[i].names); + scanf("%lf", &studentInformation[i].mathGrade); + scanf("%lf", &studentInformation[i].physicsGrade); + scanf("%lf", &studentInformation[i].englishGrade); + studentMember++; + studentInformation[i].boolNew = 1; + printf("One student has been input!\n"); +} + +void printStudentOriginalScore() { + for (int i = 0; i < studentMember; i++) { + if (studentInformation[i].stus != 0) { + printf("%s %d %s %.1f %.1f %.1f %s\n", studentInformation[i].stus, studentInformation[i].classes, studentInformation[i].names, studentInformation[i].mathGrade, studentInformation[i].physicsGrade, studentInformation[i].englishGrade, studentInformation[i].boolNew == 0 ? "" : "inserted"); + } + } +} + +void informationClear(char a[100]) { + int i = 0; + for (i = 0; i < studentMember; i++) { + if (strcmp(a, studentInformation[i].stus) == 0 || strcmp(a, studentInformation[i].names) == 0) { + memset(&studentInformation[i], 0, sizeof(studentInformation[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("Please input info of the three students\n"); + inputStudentInformation(3); + 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() +{ + char a[100]; + manage(); + printf("Enter your clear student.\n"); + scanf("%s", &a); + informationClear(a); + printStudentOriginalScore(); + return 0; +} \ No newline at end of file