#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
srand(time(NULL)); //난수 초기화
int r = rand() % 3; //0~2까지 수 중에 하나를 뽑기
printf("%d\n", r);
int r2 = rand() % 3+1; //1~3까지 수 중에 하나
printf("%d\n", r2);
int cpu, my;
scanf("%d", &my);
cpu = rand() % 3;
//0: 가위 1: 바위 2:보
if (my == cpu){
printf("비겼습니다.\n");
}else if(my == 0 && cpu == 2 || my == 1 && cpu == 0 || my == 2 && cpu == 1){
printf("이겼습니다.\n");
}else{
printf("졌습니다.\n");
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: