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. Otherwise, he believes that the day will be unlucky. Please see note section for formal definition of alternating code.If the ticket code is given. Please determine, whether the day will be successful for Selvan or not. Print "Successful Day" or "Unsuccessful Day" (without quotes) corresponding to the situation.
#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