Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/ #include <stdio.h> #include <string.h> int main() { int a,b,c; char aa[]="tesoura", bb[]="papel", cc[]="pedra", dd[]="lagarto", ee[]="Spock"; char a1[10],a2[10]; scanf("%d",&a); for(b=1; b<=a; b++) { scanf("%s%s", a1,a2); if(0==strcmp(a1,a2)) printf("Caso #%d: De novo!\n", b); else if(0==strcmp(a1,aa)) { if((0==strcmp(a2,bb)) || (0==strcmp(a2,dd))) printf("Caso #%d: Bazinga!\n", b); else if((0==strcmp(a2,cc)) || (0==strcmp(a2,ee))) printf("Caso #%d: Raj trapaceou!\n", b); } else if(0==strcmp(a1,bb)) { if((0==strcmp(a2,cc)) || (0==strcmp(a2,ee))) printf("Caso #%d: Bazinga!\n", b); else if((0==strcmp(a2,aa)) || (0==strcmp(a2,dd))) printf("Caso #%d: Raj trapaceou!\n", b); } else if(0==strcmp(a1,cc)) { if((0==strcmp(a2,aa)) || (0==strcmp(a2,dd))) printf("Caso #%d: Bazinga!\n", b); else if((0==strcmp(a2,bb)) || (0==strcmp(a2,ee))) printf("Caso #%d: Raj trapaceou!\n", b); } else if(0==strcmp(a1,dd)) { if((0==strcmp(a2,bb)) || (0==strcmp(a2,ee))) printf("Caso #%d: Bazinga!\n", b); else if((0==strcmp(a2,cc)) || (0==strcmp(a2,aa))) printf("Caso #%d: Raj trapaceou!\n", b); } else if(0==strcmp(a1,ee)) { if((0==strcmp(a2,aa)) || (0==strcmp(a2,cc))) printf("Caso #%d: Bazinga!\n", b); else if((0==strcmp(a2,bb)) || (0==strcmp(a2,dd))) printf("Caso #%d: Raj trapaceou!\n", b); } } return 0; }
//why can't we solve like that?
ReplyDelete//Whet
#include
int main()
{
int n,i;
char g1[8],g2[8];
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%s %s",g1,g2);
if(g1[0]==g2[0] && g1[1]==g2[1] ) printf("Caso #%d: De novo!\n",i);
else if(g1[0]=='p' && g1[1]=='a'&& g2[0]=='t') printf("Caso #%d: Raj trapaceou!!\n",i);
else if(g1[0]=='t' && g2[0]=='p' && g2[1]=='a') printf("Caso #%d: Bazinga!\n",i);
else if(g1[0]=='p' && g1[1]=='a' && g2[0]=='p' && g2[1]=='e') printf("Caso #%d: Bazinga!\n",i);
else if(g1[0]=='p' && g1[1]=='e' && g2[0]=='p' && g2[1]=='a') printf("Caso #%d: Raj trapaceou!\n",i);
else if(g1[0]=='p' && g1[1]=='e' && g2[0]=='l') printf("Caso #%d: Bazinga!\n",i);
else if(g1[0]=='l' && g2[0]=='p' && g2[1]=='a') printf("Caso #%d: Raj trapaceou!\n",i);
else if(g1[0]=='l' && g2[0]=='S') printf("Caso #%d: Bazinga!\n",i);
else if(g1[0]=='S' && g2[0]=='l') printf("Caso #%d: Raj trapaceou!\n",i);
else if(g1[0]=='S' && g2[0]=='t') printf("Caso #%d: Bazinga!\n",i);
else if(g1[0]=='t' && g2[0]=='S' ) printf("Caso #%d: Raj trapaceou!\n",i);
else if(g1[0]=='t' && g2[0]=='l') printf("Caso #%d: Bazinga!\n",i);
else if(g1[0]=='l' && g2[0]=='t') printf("Caso #%d: Raj trapaceou!\n",i);
else if(g1[0]=='l' && g2[0]=='p' && g2[1]=='a') printf("Caso #%d: Bazinga!\n",i);
else if(g1[0]=='p' && g1[1]=='a' && g2[0]=='l') printf("Caso #%d: Raj trapaceou!\n",i);
else if(g1[0]=='p' && g1[1]=='a' && g2[0]=='S') printf("Caso #%d: Bazinga!\n",i);
else if(g1[0]=='S' && g2[0]=='p' && g2[1]=='a') printf("Caso #%d: Raj trapaceou!\n",i);
else if(g1[0]=='S' && g2[0]=='p' && g2[1]=='e') printf("Caso #%d: Bazinga!\n",i);
else if(g1[0]=='p' && g1[1]=='e' && g2[0]=='S') printf("Caso #%d: Raj trapaceou!\n",i);
else if(g1[0]=='p' && g1[1]=='e' && g2[0]=='t') printf("Caso #%d: Bazinga!\n",i);
else if(g1[0]=='t' && g2[0]=='p' && g2[1]=='e') printf("Caso #%d: Raj trapaceou!\n",i);
}
return 0;
}