#include <stdio.h>
#include <malloc.h>

typedef struct Student{
    char name[30];
    int kor;
    int eng;
    int math;
    int total;
    int avg;
    struct Student* next;
} Student

Student* head = NULL;

void addStudent() {
    Student* newNode = (Student*)malloc(sizeof(Student));
    if (!newNode) {
        printf("메모리 할당 실패");
        return;
    }

    printf("\n[학생 성적 입력]\n");
    printf("이름: ");
    scanf("%s", newNode->name);
    printf("국어 점수: ");
    scanf("%s", newNode->kor);
    printf("영어 점수: ");
    scanf("%s", newNode->eng);
    printf("수학 점수: ");
    scanf("%s", newNode->math);
    newNode->total = newNode->kor + newNode->eng + newNode->math;
    newNode->avg = newNode->total / 3.0f;
    newNode->next = NULL;

    if(head == NULL) {
        head = newNode;
    } else{
        Student* p = head;
        while(p->next != NULL)
            p = p->next;
        p->next = newNode
    }

    printf("\n>>> 입력 완료! 메뉴로 돌아갑니다. \n\n");
}

void main(){
    int menu;

    while(1){
        printf("===== Menu =====\n");
        printf("1. 성적 입력\n");
        printf("1. 성적 확인\n");
        printf("1. 종료\n");
        printf("선택 (1~3): ");
        scanf("%d", &menu);

        if (menu == 1) {
            addStudent();
        }

        else if (menu == 2) {
            printStudents();
        }
            
        else if (menu == 3) {
            printf("\n프로그램이 종료됩니다.\n");
        }

        else {
            printf("\n잘못된 번호입니다. 다시 입력하세요.\n\n");
        }
    }

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: