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; }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)
+ 2
No 1 rule in codind: The computer doesn't make a mistake it's the user.
+ 2
That's what a friend told me.