What's an error with my code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
19th Jul 2020, 11:57 AM
Raju
Raju - avatar
3 Answers
+ 1
Nothings Wrong....
19th Jul 2020, 12:05 PM
Abdul Muizz
Abdul Muizz - avatar
+ 1
Change your code like this↓ #include<iostream> using namespace std; int main() { string str; int i=0,j,a=0; getline(cin,str); int x=str.size(); for(;i<x;i++) { char first=str[i]; for(j=i+1;j<x;j++) { char second=str[j]; if(first==second) a+=1; } } if(a>=1) cout<<"DejaVu"; else cout<<"Unique"; //cout<<z; return 0; } In your code you didn't add string length .
19th Jul 2020, 12:30 PM
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ - avatar
19th Jul 2020, 12:38 PM
Ćheyat
Ćheyat - avatar