i can't find the error why wa??

#include
#include

using namespace std;

int main()
{
int t;

cin>>t;

string h;

getline(cin,h);

while(t--)
{
     string s1;
     string s2[4];
     int c=0;

    getline(cin,s1);
    for(int i=0;i<4;i++) cin>>s2[i];


    for(int i=0;i<4;i++)
    {
        if(s1.find(s2[i]) !=string::npos) c++;
    }

    if(c<2) cout<<"dissimilar\n";
    else cout<<"similar\n";

     getline(cin,h);


}

return 0;

}

The error was that u didn’t write ‘#’ before including the the libraries .

Just add that and your code will work:)

actually he added ‘#’ but since he just pasted it directly # is converted into heading due to markdown.

Can u tell he question

The error is because you are comparing parts of the string and not the whole word for example
tc#1
1
cook chef is good
coo ch no bad
will give you output similar but the result should be dissimilar
the reason for the output to be similar is s1.find(s2[i]) if true for coo as it finds “coo” in “cook” :confused:
So just take 2 string 1-D arrays of size 4 and compare each word if then c>2 print similar else dissimilar. I
hope this helps :)!!

1 Like