|
@ -17,13 +17,24 @@ void schereSteinPapier() |
|
|
scanf("%d", &user); |
|
|
scanf("%d", &user); |
|
|
if(user == 0) |
|
|
if(user == 0) |
|
|
{ |
|
|
{ |
|
|
|
|
|
printf("Vielen Dank fürs Spielen! Tschau!\n"); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
else if(user == 1 || user == 2 || user == 3) |
|
|
else if(user == 1 || user == 2 || user == 3) |
|
|
{ |
|
|
{ |
|
|
srand(time(NULL)); |
|
|
srand(time(NULL)); |
|
|
com = rand() % 3 + 1; |
|
|
com = rand() % 3 + 1; |
|
|
printf("%d\n",com); |
|
|
|
|
|
|
|
|
int win = calculateWinner(user, com); |
|
|
|
|
|
switch (win) |
|
|
|
|
|
{ |
|
|
|
|
|
case(-1):printf("Der Computer hat %d gewaehlt, Du hast verloren!!!\n\n", com); |
|
|
|
|
|
break; |
|
|
|
|
|
case(0): printf("Der Computer hat %d gewaehlt, Es steht unentschieden!!!\n\n", com); |
|
|
|
|
|
break; |
|
|
|
|
|
case(1): printf("Der Computer hat %d gewaehlt, Du hast gewonnen!!!\n\n", com); |
|
|
|
|
|
break; |
|
|
|
|
|
default: printf("Error!"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
@ -31,3 +42,41 @@ void schereSteinPapier() |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int calculateWinner(int x, int y) |
|
|
|
|
|
{ |
|
|
|
|
|
switch (x) |
|
|
|
|
|
{ |
|
|
|
|
|
case(1): |
|
|
|
|
|
switch (y) { |
|
|
|
|
|
case(1): return 0; |
|
|
|
|
|
|
|
|
|
|
|
case(2): return -1; |
|
|
|
|
|
|
|
|
|
|
|
case(3): return 1; |
|
|
|
|
|
|
|
|
|
|
|
default: return 3; |
|
|
|
|
|
} |
|
|
|
|
|
case(2): |
|
|
|
|
|
switch (y) { |
|
|
|
|
|
case(1): return 1; |
|
|
|
|
|
|
|
|
|
|
|
case(2): return 0; |
|
|
|
|
|
|
|
|
|
|
|
case(3): return -1; |
|
|
|
|
|
|
|
|
|
|
|
default: return 3; |
|
|
|
|
|
} |
|
|
|
|
|
case(3): |
|
|
|
|
|
switch (y) { |
|
|
|
|
|
case(1): return 1; |
|
|
|
|
|
|
|
|
|
|
|
case(2): return -1; |
|
|
|
|
|
|
|
|
|
|
|
case(3): return 0; |
|
|
|
|
|
|
|
|
|
|
|
default: return 3; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |