I want to write a program which prints Real Fancy if the given string contains "NOT" or "not" and regularly fancy if it doesn't contain not.
Ex: "this is not a string" o/p: Real Fancy
"this is nothing" o/p: regularly fancy
The problem is it prints Real Fancy if my first testcase input is "not is this line". But if the same line is given as input in second or above testcase it is not working and printing regularly fancy.Why? Any help?
Here is the code:
#include <bits/stdc++.h>
using namespace std;
int main()
 {
   int t;//No.of test cases
   cin>>t;
   while(t--)
   {
    string quote;//the input from user
    string found="not";//word to be found
    string temp="";
    int not_found=0;
    cin.ignore();
    getline(cin,quote);
    //Splitting the given line into words and store in a vector
    vector<string> words;
    istringstream iss(quote);
    copy(istream_iterator<string>(iss),
    istream_iterator<string>(),
    back_inserter(words));
   //Scan for "not" and if found break from for loop
    for(int i=0;i<words.size();i++)
    {
        temp=words[i];
        transform(temp.begin(),temp.end(),temp.begin(),::tolower);
        if(temp==found)
        {
            cout<<"Real Fancy"<<endl;
            not_found=1;
            break;
        }
       }
      if(not_found==0)
        cout<<"regularly fancy"<<endl;
    }
    return 0;
 }
 
    