C/Academy
학생입력 프로그램
갈릭새우칩
2019. 6. 26. 21:49
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> int index = 0; struct Student { int m_number; char m_name[10]; double m_grade; }; void InputData(struct Student *); void PrintList(struct Student *); int main(void) { struct Student s[100]; int order = 0; while (order != 3) { printf("=====================\n1 입력, 2 출력, 3 종료\n=====================\n"); scanf("%d", &order); switch (order) { case 1: InputData(s); break; case 2: PrintList(s); break; case 3: printf("종료합니다.\n"); break; } } return 0; } void InputData(struct Student *s) { printf("학번을 입력하세요 "); scanf("%d", &s[index].m_number); printf("\n이름을 입력하세요 "); scanf("%s", &s[index].m_name); printf("\n학점을 입력하세요 "); scanf("%lf", &s[index].m_grade); index++; } void PrintList(struct Student *s) { for (int i = 0; i < index; i++) { printf("\n학번\t이름\t학점 \n"); printf("%d\t%s\t%lf\t\n", s[i].m_number, s[i].m_name, s[i].m_grade); } } | cs |