/* 2026년 5월 7일
202606017 나경문
9주차 퀴즈 코드 작성 */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define MAX 30
void myinfo() {
printf("202606017 나경문");
}
int getNum() //랜덤하게 인덱스(0~29)를 반환하는 함수
{
return rand() % MAX;
}
//가상 데이터 학번 30개 (전역 변수)
int studentID[30] = {
20240001, 20220002, 20240003, 20250011, 20240005,
20230007, 20240007, 20240008, 20240009, 20240010,
20240011, 20240012, 20240013, 20240014, 20240015,
20240016, 20250017, 20230022, 20250012, 20240020,
20240021, 20240001, 20240023, 20240024, 20240025,
20240026, 20260027, 20240028, 20240029, 20240030
};
int main() {
myinfo();
// 현재 시간을 시드로 사용하여 매번 다른 난수 생성
srand( time( NULL ) );
printf("\n");
for (int i=0; i<3; i++)
printf("%d 학우님 축하드립니다!\n", studentID[getNum()]);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: