I found a problem in Codechef.Here is the question. The task was to find the most likely character from the given string. Firstly, I tried with == operator and then with strcmp() function. but in both cases, the intended output is not coming. In python it can be easily done with "in" operator but how to do this in c so that I get the required result.
#include <stdio.h>
#include <string.h>
int main(void) {
char st[3];
gets(st);
puts(st);
//scanf("%[^\n]%*c", st);
//printf("%s\n", st);
if (!(strcmp(st,"R B") ||strcmp(st,"R R")||strcmp(st,"R G")||strcmp(st,"B R")||strcmp(st,"G R")))
printf("R");
else if (!(strcmp(st,"B B") ||strcmp(st,"B G")||strcmp(st,"G B")))
printf("B");
else
printf("G");
/*if(s=="R B"||s=="R R"||s=="R G"||s=="B R"||s=="G R")
printf("R");
else if(s=="B B"||s=="B G"||s=="G B")
printf("B");
else if(s=="G G")
printf("G");*/
return 0;
}