flrto

C 언어 가위 바위 보 본문

C/Academy

C 언어 가위 바위 보

갈릭새우칩 2019. 6. 12. 20:39
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
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 
int main()
{
    int x = 0;
    int com = 0;
    srand(time(NULL));
 
    printf("1 가위 2 바위 3 보\n\n");
    scanf("%d"&x);
    com = (rand() % 3+ 1;
 
    if (x == 1)
    {
        printf("나 가위 ");
    }
    else if (x == 2)
    {
        printf("나 바위 ");
    }
    else if (x == 3)
    {
        printf("나 보 ");
    }
 
    if (com == 1)
    {
        printf("컴터 가위 ");
    }
    else if (com == 2)
    {
        printf("컴터 바위 ");
    }
    else if (com == 3)
    {
        printf("컴터 보 ");
    }
    printf("\n\n");
 
    if (com == x)
    {
        printf("비겼다\n");
    }
    else if (com == 1 && x == 3 || com == 2 && x == 1 || com == 3 && x == 2)
    {
        printf("컴퓨터가 이겼다.\n");
    }
    else if (com == 1 && x == 2 || com == 2 && x == 3 || com == 3 && x == 1)
    {
        printf("내가 이겼다.\n");
    }
 
    printf("\n\n");
    
    return 0;
}
 
Comments