+ 1

what it's problem ?

I want it to add 1 to g if the input was w , and add 1 to f if the input was r , until one of them (f or g) reach 3 , and then show the winner ! #include <iostream> using namespace std; int main(){ int g=0,f=0; char c; cin>>c; switch(c){ case 'w': g++; break; case 'r': f++; break; if (g>=3||f>=3) cout<<g; cout<<f; break; } return 0;

24th Jul 2019, 4:13 PM
Hannah
Hannah - avatar
10 Respostas
+ 2
https://code.sololearn.com/c3E7U4H8osFT/?ref=app here is the problem solved with both things edit: cool Now it works properly, I had to redefine "c" at the start of every loop
24th Jul 2019, 4:45 PM
alvaro.pkg.tar.zst
alvaro.pkg.tar.zst - avatar
+ 2
now i understand , thanks for being patient enough to help me !
24th Jul 2019, 4:59 PM
Hannah
Hannah - avatar
+ 1
You have to insert everything into a while loop
24th Jul 2019, 4:34 PM
alvaro.pkg.tar.zst
alvaro.pkg.tar.zst - avatar
+ 1
i dont understand ... Would you post the right form for me ?
24th Jul 2019, 4:36 PM
Hannah
Hannah - avatar
+ 1
First of all the program ends when the user insert the input once, the other problem is that you have to make one if statement when g wins and another one when f wins, if you put both in one if statement both will show up
24th Jul 2019, 4:38 PM
alvaro.pkg.tar.zst
alvaro.pkg.tar.zst - avatar
+ 1
so could you post the corrected form here if possible ?
24th Jul 2019, 4:45 PM
Hannah
Hannah - avatar
+ 1
but thats not correct dear Alvaro 1234 !
24th Jul 2019, 4:49 PM
Hannah
Hannah - avatar
+ 1
Sorry, I didn't read the thing properly, it should be good now
24th Jul 2019, 4:50 PM
alvaro.pkg.tar.zst
alvaro.pkg.tar.zst - avatar
+ 1
not correct even now dear ... what are these : >: >: >:
24th Jul 2019, 4:53 PM
Hannah
Hannah - avatar
+ 1
It's a small decoration for when the user has to insert input, the thing is that if you don't input anything the program will print that forever, and in solo learn console you have to input the options in one go, it would be better if you could compile it and run it in a native console
24th Jul 2019, 4:56 PM
alvaro.pkg.tar.zst
alvaro.pkg.tar.zst - avatar