+ 1

why "--x" gives output until time limit is not exceeded?

https://code.sololearn.com/c7NSwM4loV88/?ref=app

2nd Apr 2017, 1:03 PM
Dhananjay Panage
Dhananjay Panage - avatar
2 ответов
+ 14
#include <iostream> using namespace std; int main() { for(int i = 0; i <= 3; --i) cout<<"#*"; return 0; } In this code, the value of i will always remain below 3 when you subtract it. So it caused an infinite loop and the Sololearn compiler only compiled till the time limit exceeded
2nd Apr 2017, 1:11 PM
Chirag Bhansali
Chirag Bhansali - avatar
+ 3
If you keep subtracting from zero it will always remain <3. So it is an infinite loop where x never >3.
2nd Apr 2017, 1:13 PM
Ritik Pal
Ritik Pal - avatar