Ujjawaldx

Untitled

Jan 2nd, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     char str[5000];
  6.     cin.getline(str,5000);
  7.     while(str[0]!='*')
  8.     {
  9.         char *p=strtok(str," ");
  10.         char f=toupper(str[0]);
  11.         while(p!=NULL)
  12.         {
  13.             if(toupper(*p)!=f)
  14.                 break;
  15.             else
  16.                 p=strtok(NULL," ");
  17.         }
  18.         if(p!=NULL)    //While loop terminated but still words are present in the sentence
  19.             cout<<"N"<<endl;
  20.         else
  21.            cout<<"Y"<<endl;
  22.           cin.getline(str,5000);
  23.     }
  24.     // your code goes here
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment