Every day, Selvan goes to his office by train and buys the ticket from the counter on the day of travel. On the ticket, there is a letter-code that is represented as a string of upper-case Latin letters.Selvan believes that the day will be successful in case exactly two different letters in the code alternate.
#include <stdio.h>
int main()
{ int n;
char ticketnumber[102];
scanf("%d",&n);
for (int i=0;i<n;i++)
{
scanf("%s",ticketnumber);
if(ticketnumber[0]!=ticketnumber[2]||ticketnumber [1]!=ticketnumber[3]||ticketnumber[3]!=ticketnumber [5])
{printf("NO\n");}
else
{printf("YES\n");}
}
return 0;
}
Comments
Post a Comment