0
Please tell me 🙂
(1) Why i am unable to write rock , paper , seccior in place of r , p , s in dict[50] ? How may i ? (2) why it is giving wrong winner when rock vs paper ? https://code.sololearn.com/cRaAthdnqI1I/?ref=app
5 odpowiedzi
+ 1
It's a single dimentional character array so you can write characters only, not strings..
If you want string then use 2 dimensional array dict[3][50];
Add return type for:
int greater(char player, char computer);
Edit:
Oh.. 2nd question!!!
For : 2 can some other may answer, need time to check
0
Jayakrishna🇮🇳 thanks sir ☺️ please answer 2nd questions also whenever you have time .
0
To check you winner change your RPS to an enum, use math to see if it's 0 1 or 2 difference, 0 is a tie 1 means P or S won 2 means R won.
0
William Owens actually sir it is giving me wrong winner only when user choose rock and system choose paper . Otherwise in all conditions it is giving right answer i think .
0
Abhay mishra
According to your logic, here :
You know, Either if or else executes so for any value other than player = 'p' and system 's', it returns 0;
if ((player == 'p') && (computer == 's'))
{
printf("win %c\n",computer);
return 1;
}
else
{
printf("win %c\n",player);
return 0;
}
You should go like :
if ( player == 'p') {
if(computer=='s')
return 1;
else
return 0;
..
}
else if(player == 's') {
...
..
}
else {
...
}