Need to know a little more about string.char an locale library.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#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; } |