0

I always get no output after running my C and C++ code on challenges, like this one below. Why?

#include <iostream> #include <string> using namespace std; int main() { string str; cin >> str; int i = 0, tmpG, tmpM, tmpT; int len = str.length(); cout << str[2]; while (i <= len) { if (str[i] == 'G') { tmpG = i; } else if (str[i] == 'T') { tmpT = i; } else if (str[i] == '

#x27;) { tmpM = i; } else { continue; } i++; } if ((tmpM < tmpG && tmpT < tmpG) || (tmpM > tmpG && tmpT > tmpG)) { cout << "ALARM"; } else { cout << "quiet"; } return 0; }

5th Nov 2022, 4:59 PM
Dulgan Danjuma
Dulgan Danjuma - avatar
3 Respuestas
+ 2
Just remove the: else{ continue; } this makes the loop an infinite loop so it gives no output and loop should be: while(i<len)
5th Nov 2022, 5:29 PM
Just Some Random Guy
Just Some Random Guy - avatar
+ 2
No 1 rule in codind: The computer doesn't make a mistake it's the user.
6th Nov 2022, 4:31 PM
Girish Tibatina
Girish Tibatina - avatar
+ 2
That's what a friend told me.
6th Nov 2022, 4:31 PM
Girish Tibatina
Girish Tibatina - avatar