12243

Need to know a little more about string.char an locale library.

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <locale>

using namespace std;

int main()
{
	string str;
	locale loc;
	while(getline(cin,str))
	{
		if(str=="*")
		break;

		char ch1;
		char ch=str[0];
		if(isupper(ch,loc))
		ch1=tolower(ch,loc);
		else
		ch1=toupper(ch,loc);
		//cout<<ch<<" "<<ch1<<"\n";
		bool tautogram=1;
		for(int i=1;i<str.size();i++)
		{
			if(str[i]==' ')
			{
				if(i+1<str.size() && str[i+1]!=ch && str[i+1]!=ch1)
				{
					//cout<<"error "<<str[i+1]<<"\n";
					tautogram=0;
					i=str.size();
				}
			}
		}
		if(tautogram)
		cout<<"Y\n";
		else
		cout<<"N\n";
	}
	return 0;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *