#include <iostream>
#include <string.h>
using namespace std;
int main () {
string str2 (" not ");
string str3 ("not ");
string str4 ("not");
int T;
cin>>T;
for (int k=0;k<T;k++){
string str ;
cin >> str;
// read the newline character
getchar();
int len = str.size();
//condition for only not as a sentence
if ((str.find(str4) != string::npos) && len ==3) {
cout<<"Real Fancy";
}
// condition to check for not word in middle of a sentence eg. this is not good
else if ((str.find(str2) != string::npos) ) {
cout<<"Real Fancy";
}
// condition if the statement ends with the word not
else if (str[len-1]=='t' && str[len-2]== 'o' && str[len-3]== 'n' && str[len-4]== ' '){
cout<<"Real Fancy";
}
// code to check for if statement starts with word not
else if ((str.find(str3) != string::npos) ) {
cout<<"Real Fancy";
}
else {
cout<<"regularly fancy";
}
cout<<endl;
}
return 0;
}
You should use something like
If(s.find(“not”)!=-1)
Cout<<“realfancy”;
else
Cout<<“regular fancy”;
This will check if you have not in the string or not
yup when i saw you participated quite well in lunchtime and other cookoffs
i got amazed how come you are still a one star coder.
so whats your story how did you lose and slide down to one star ?
but but this will give wrong answer
suppose the string is “This is nothing”
then also we will get output as “Real Fancy”
but this will be wrong.
you got my point ?
besides can you help me how to start learning for CP
as i just started coding in C++ and straight away came to codechef as its really challenging
So what all topics should i start to learn first ??
Well if you have just started then you should get your basics fixed first…try to solve easy problems first then move to codechef contests . Like you can go to codeforces and start solving problems in descending order of submission it will help you to boost your confidence and for C++ you must learn STL so that you can use concepts of map stack set and all in you programme .don’t just rush because you won’t be a great programmer in a day .it will take time and if you keep working hard then results will follow so for now I will suggest you two things
Do codeforces from descending order of submission
2.learn from geek for geeks
And keep trying in the live challenges no matter how your rating is as it will increase eventually if you are working hard constantly…hope this helps
I am about to post a collection of link’s I have found out for preparing for ACM-ICPC …it might help you a lot … I am just working to fix it’s alignment asap
thnx for support
BTW i found the problem myself teh problem is that once i take an input from the user what my compiler does is it stores a all characters before a whitespace and then the next word is automatically stored into another string for instance
suppose my custom input console ;looks like :
3
not working
hey
what is this
the output i wil get will be
Real FAncy // as it sees not as one string
regularly fancy // sees working as the 2nd string 2nd word of the first string
regularly fancy // sees hey as the third string
#include <iostream>
#include <string.h>
using namespace std;
int main () {
string str2 (" not ");
string str3 ("not ");
string str4 ("not");
int T;
cin>>T;
for (int k=0;k<T;k++){
string str ;
getline(cin,str);
int len = str.size();
//condition for only not as a sentence
if ((str.find(str4) != string::npos) && len ==3) {
cout<<"Real Fancy";
}
// condition to check for not word in middle of a sentence eg. this is not good
else if ((str.find(str2) != string::npos) ) {
cout<<"Real Fancy";
}
// condition if the statement ends with the word not
else if (str[len-1]=='t' && str[len-2]== 'o' && str[len-3]== 'n' && str[len-4]== ' '){
cout<<"Real Fancy";
}
// code to check for if statement starts with word not
else if ((str.find(str3) != string::npos) ) {
cout<<"Real Fancy";
}
else {
cout<<"regularly fancy";
}
cout<<endl;
}
return 0;
}