/* 13주차 퀴즈 과제
2026-06-04
202606017 나경문 */
#include <stdio.h>
#include <string.h>
void myinfo() {
printf("202606017 나경문");
}
typedef struct quiz {
char question [100]; //질문 배열
char solution [100]; //정답 배열
}QUIZ;
char user_answer[100];
int main() {
//개그 답 직접 입력
QUIZ Q[3] = {
{"별 중에 가장 슬픈 별은?", "이별"},
{"진짜 새의 이름은 무엇일까요?", "참새"},
{"고기 먹을 때마다 따라오는 개는?", "이쑤시개"}
};
// for문을 통해 퀴즈 1 2 3을 검사해서 답 확인을 해야
for (int i = 0; i < 3; i++) {
// 질문을 화면에 출력
printf("%s", Q[i].question);
// 사용자의 답을 입력받음 (띄어쓰기 없는 단답형이므로 %s 사용)
scanf("%s", user_answer);
// 3. strcmp()를 이용해 입력한 답과 구조체 답 비교
// strcmp는 두 문자열이 완벽히 일치하면 0을 반환
if (strcmp(user_answer, Q[i].solution) == 0) {
printf("\"%s\"정답!\n", user_answer);
} else {
// 정답이 아니면 땡과 함께 원래 정답을 보여줌
printf("\"%s\"땡!정답은 %s\n", user_answer, Q[i].solution);
}
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: