+ 2

Whats wrong with Jungle Camping?[SOLVED]

This is my code but it is failing last test case What's wrong? https://code.sololearn.com/cJBQgfgEsuAm/?ref=app My code is not getting public, it says "Can't mKe your code public so am Posting here" // Input sounds #include <iostream> #include <string> using namespace std; int main() { string str, str1, str2, str3, str4; cin >> str1; cin >> str2; cin >> str3; cin >> str4; str = str1 + str2 + str3 + str4; //your code goes here string sound("GRSC"); string final; char lion = sound[0]; char tiger = sound[1]; char snake = sound[2]; char bird = sound[3]; int strL = str.size(); for(int i = 0; i < strL; i++){ char letter = str[i]; if(letter == lion){ final += "Lion "; } if(letter == tiger){ final += "Tiger "; } if(letter == snake){ final += "Snake "; } if(letter == bird){ final += "Bird "; } }

29th Dec 2019, 3:37 PM
Sarthak Gupta
Sarthak Gupta - avatar
2 ответов
0
Yeah that's the reason your code is not able to take more than 4 sounds. But limit to the sound is nowhere defined in the problem. So may be in the hidden test cases they give more then 4 sounds as input. And then your code will fail. That may be the reason to why you think your question is not answered yet because Coder Kitten answer seems correct and everybody thinks that question is already answered. If you are still in doubt contact me on dm.
15th Jan 2020, 4:47 PM
InfinityAJ
InfinityAJ - avatar