Whats wrong with the second one that i have written?-I have used gets() instead of scanf(),which i have used in the first code,for reading the strings and i was shown that it is a wrong answer.
#include<stdio.h>
void main()
{
int count;
char a[4];
char b[4];
scanf("%d",&count);
while(count–)
{
scanf("%s",a);
scanf("%s",b);
if((a[0]==‘b’||b[0]==‘b’)&&(a[1]==‘o’||b[1]==‘o’)&&(a[2]==‘b’||b[2]==‘b’))
printf(“yes\n”);
else if((a[0]==‘o’||b[0]==‘o’)&&(a[1]==‘b’||b[1]==‘b’)&&(a[2]==‘b’||b[2]==‘b’))
printf(“yes\n”);
else if((a[0]==‘b’||b[0]==‘b’)&&(a[1]==‘b’||b[1]==‘b’)&&(a[2]==‘o’||b[2]==‘o’))
printf(“yes\n”);
else
printf(“no\n”);
}
}
#include<stdio.h>
#include<string.h>
void main()
{
int count;
char a[4];
char b[4];
scanf("%d",&count);
while(count–)
{
gets(a);
gets(b);
if((a[0]==‘b’||b[0]==‘b’)&&(a[1]==‘o’||b[1]==‘o’)&&(a[2]==‘b’||b[2]==‘b’))
printf(“yes\n”);
else if((a[0]==‘o’||b[0]==‘o’)&&(a[1]==‘b’||b[1]==‘b’)&&(a[2]==‘b’||b[2]==‘b’))
printf(“yes\n”);
else if((a[0]==‘b’||b[0]==‘b’)&&(a[1]==‘b’||b[1]==‘b’)&&(a[2]==‘o’||b[2]==‘o’))
printf(“yes\n”);
else
printf(“no\n”);
}
}