Advertisement
sp_Showrav

stringconstuct

May 20th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     string str;
  6.     getline(cin, str);
  7.     string key[] = {"for", "if", "double", "int", "string", "else", "char", "while"};
  8.     int length = sizeof(key)/sizeof(key[0]);
  9.     for(int i=0; i<length; i++){
  10.  
  11.             string found = key[i];
  12.             if(str.find(found) != string::npos) {
  13.             cout << found << " -> yes" << endl;
  14.         } else {
  15.             cout << found << " -> no" << endl;
  16.         }
  17.  
  18.     }
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement