i wrote down this code, then compiled it, it seemed okay, but when i submitted it's getting WA
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main ()
{
char w[10000], a, b;
int x;
while (w[0] !='*')
{
cin.getline(w,9999);
x=(strlen(w))-1;
a = tolower(w[0]);
for (int i=0; i<x; i++)
{
if (w[i]==' ')
{
i++;
if (a == ' ')
a=tolower(w[i]);
else
{
b = tolower(w[i]);
if (a!=b)
{
break;
}
}
}
}
if (a==b)
cout << "Y"<< endl;
else
cout << "N" << endl;
}
}
can anyone help me?