0
Skee-Ball from Code Coach C++
Failure in test case 3. I thought reason was that is impossible to divide on 0. But I found solution. This code is working on my PC. include <iostream> using namespace std; int main() { int points, costintickets, ticket, guns; cin >> points; ticket = points / 12; cin >> costintickets; if (costintickets <= 0) { costintickets = 1; } guns = ticket / costintickets + 1; if (guns >= 2) { cout << "Buy it!"; } else { cout << "Try again"; } return 0; } Anyway failure is still there. What can be the case?
4 Respuestas
+ 3
No. Of tickets = points/12
If no. Of tickets >= cost
Print get it
Else print try again
thats all the logic you need. Dont overcomplicate the code.
+ 2
Just remove the first if.
Second if compare ticket >= costintickets
+ 2
Thanks!
+ 2
Create A You're welcome.