Any idea why this isn't working quite right? I'm stumped.
#include <stdio.h>
/*
ROCK 1
PAPER 2
SCISSOR 3
*/
int user_choice = 0;
int computer_choice = 0;
void do_get_input()
{
printf("Please choose 1, 2, or 3.\nRock being 1, Paper being 2 and Scissors being 3.\n");
scanf("%d", &user_choice);
if (user_choice != '1' || user_choice != '2' || user_choice != '3')
{
printf("Your choice was invalid. Choose again.\n");
scanf("%d", &user_choice);
}
}
void do_who_wins()
{
rand(computer_choice)%4;
if (computer_choice == '1' && user_choice == '1')
{
printf("You tied.\n");
}
else if (computer_choice == '1' && user_choice == '2')
{
printf("You win!\n");
}
else if (computer_choice == '1' && user_choice == '3')
{
printf("You loose!\n");
}
else if (computer_choice == '2' && user_choice == '1')
{
printf("You loose!\n");
}
else if (computer_choice == '2' && user_choice == '2')
{
printf("You tie.\n");
}
else if (computer_choice == '2' && user_choice == '3')
{
printf("You win!\n");
}
else if (computer_choice == '3' && user_choice == '1')
{
printf("You win!\n");
}
else if (computer_choice == '3' && user_choice == '2')
{
printf("You loose!\n");
}
else if (computer_choice == '3' && user_choice == '3')
{
printf("You tie.\n");
}else{
printf("Bug: Do_who_wins");
}
}
int main()
{
do_get_input();
do_who_wins();
return 0;
}