-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrpc.c
More file actions
109 lines (98 loc) · 3.15 KB
/
Copy pathrpc.c
File metadata and controls
109 lines (98 loc) · 3.15 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <time.h>
int usrScore = 0, compScore = 0;
void checkOpt(int usr, int comp){
//1 = pedra 2=papel 3=tesoura (Pedra = Rock, 2 = Paper, 3 = Scissors)
if (usr == comp){
printf(" ------------------\n");
printf("| Empate! |\n");
printf(" ------------------\n");
}
else if(usr == 3){
if (comp == 2){
printf(" --------------------\n");
printf("| Voce venceu! :) |\n");
printf("|Sua Escolha:Tesoura |\n");
printf("| Computador: Papel |\n");
printf(" --------------------\n");
usrScore++;
}
else {
printf(" -------------------\n");
printf("| Voce perdeu! :( |\n");
printf("|Sua Escolha:Tesoura|\n");
printf("|Computador:Pedra |\n");
printf(" -------------------\n");
compScore++;
}
}
else if (usr == 1){
if(comp == 3){
printf(" ------------------\n");
printf("| Voce venceu! :) |\n");
printf("|Sua Escolha: Pedra|\n");
printf("|Computador:Tesoura|\n");
printf(" ------------------\n");
usrScore++;
}
else{
printf(" ------------------\n");
printf("| Voce perdeu! :( |\n");
printf("| Sua Escolha:Pedra |\n");
printf("| Computador: Papel |\n");
printf(" ------------------\n");
compScore++;
}
}
else if (usr == 2){
if(comp == 1){
printf(" ------------------\n");
printf("| Voce venceu! :) |\n");
printf("| Sua Escolha:Papel |\n");
printf("| Computador: Pedra |\n");
printf(" ------------------\n");
usrScore++;
}
else{
printf(" ------------------\n");
printf("| Voce perdeu! :( |\n");
printf("| Sua Escolha:Papel |\n");
printf("| Computador:Tesoura|\n");
printf(" ------------------\n");
compScore++;
}
}
else if(usr == 4){
printf(" ------------------\n");
if(usrScore > compScore){
printf("| Voce venceu! |\n");
}
else if (usrScore < compScore){
printf("| Voce perdeu! |\n");
}
else {
printf("| Empate! |\n");
}
printf("| Resultado |\n");
printf("| Voce: %d |\n", usrScore);
printf("| Computador: %d |\n", compScore);
printf(" ------------------\n");
}
}
int main(){
int esc, compEsc;
srand(time(0));
printf("\t\t\t\t=============|Bem-Vindo ao Pedra, papel e tesoura|============");
while (esc != 4){
printf("\nPor favor escolha uma opcao: ");
printf("\n1.Pedra");
printf("\n2.Papel");
printf("\n3.Tesoura");
printf("\n4.Sair\n");
scanf("%d", &esc);
compEsc = (rand() % 3)+1;
checkOpt(esc, compEsc);
}
}