0

How to i get input character by character pair ❓

Title: The Rock, Paper, Scissor Game Problem: Glin and Rick are school friends. One day they thought to play Rock, Paper, Scissor but they don't understand the game. So the Dcoder team decided to help them playing.They need your help to show them a demo of the game, but as you Guys know Dcoder is all about programming, You have to code the game and play it with one of the engineer at Dcoder, will be represented by "Dcoder" Input: First Line contains the number of times game was played (n), next line contains n pairs of R ,P or S, The first letter in the pair is for player "Dcoder" and next letter is for player "You" Output: For each Pair output Dcoder or You in a new line, based on which player wins.In case of draw output Draw. Winning Criteria: The game is a draw if both players choose the same item. Paper wins over rock because paper covers rock. Scissors wins over paper because scissors cuts paper. Rock wins over scissors because rock breaks scissors.

22nd Oct 2019, 6:29 PM
aejaz ahmed
aejaz ahmed - avatar
3 Answers
+ 1
put this on code playground, and link it here
22nd Oct 2019, 8:09 PM
✳AsterisK✳
✳AsterisK✳ - avatar
0
/*its my code help me how to read character by character pair */ #include<stdio.h> int main() { int n,i,j; char dco[]={"RRS"}; char y[]={"RSR"}; scanf("%d",&n); for(i=0; i<n; i++) { for(j=i; j==i; j++){ if(dco[i]==y[i]) printf("Draw\n"); else if(dco[i]=='P' && y[i]=='R' || dco[i]=='R' && y[i]=='P') { if(dco[i]=='P') printf("Dcoder\n"); else printf("You"); } else if(dco[i]=='S' && y[i]=='P' || dco[i]=='P' && y[i]=='S') { if(dco[i]=='S') printf("Dcoder\n"); else printf("You"); } else if(dco[i]=='R' && y[i]=='S' || dco[i]=='S' && y[i]=='R') { if(dco[i]=='R') printf("Dcoder\n"); else printf("You"); } } } return 0; }
22nd Oct 2019, 6:32 PM
aejaz ahmed
aejaz ahmed - avatar
23rd Oct 2019, 3:33 AM
aejaz ahmed
aejaz ahmed - avatar