|
|
back to boardHelp me please! Posted by Roa28 4 Mar 2014 00:13 Только начал изучать С++. Решаю задачки для новичков. Что не так здесь? #include <iostream> #include <conio.h> using namespace std; int main() { int A; cout << "How many?"; cin >> A; if(A < 1 || A > 2000) { cout << "wrong input!"; }else { if(A <= 4) cout << "few"; else if(A <= 9) cout << "several"; else if(A <= 19) cout << "pack"; else if(A <= 49) cout << "lots"; else if(A <= 99) cout << "horde"; else if(A <= 249) cout << "throng"; else if(A <= 499) cout << "swarm"; else if(A <= 999) cout << "zounds"; else cout << "legion";} return 0; } Re: Help me please! Posted by Roa28 4 Mar 2014 00:14 компилировал на Visual studio 2012 - все работает. почему тут не принимает? Re: Help me please! don`t write How many it is wrong : and not "||" you should "&&" it is true good luck Re: Help me please! Posted by KKKK 15 Jan 2018 18:24 #include <iostream> using namespace std; int main() { int a; cin >> a; if (a >= 1 and a <= 4){ cout << "few"; if (a >= 5 and a <= 9){ cout << "several"; if (a >= 10 and a <= 19){ cout << "pack"; if (a >= 20 and a <= 49){ cout << "lots"; if (a >= 50 and a <= 99){ cout << "horde"; if (a >= 100 and a <= 249){ cout << "throng"; if (a >= 250 and a <= 499){ cout << " swarm"; if (a >= 500 and a <= 999){ cout << " zounds"; if (a > 1000){ cout << " legion"; } } |
|
|