+ 4
Help pls
9 odpowiedzi
+ 5
Read the task description again carefully.. You may be misunderstood it.
If popsicles evenly distributed to siblings then print give away otherwise eat them yourself.
+ 4
If input 3 9 then you can give 3 siblings each 3 popsicles.
If input is 4 10 then you cannot evenly distribute because for each 4 siblings giving 2 popsicles will be 4*2=8 but 10-8 = 2 left so you can't give away. Eat them your self.
Hope now you can understand, what is the task and mistake in your code...
edit:
GamerGeil Hd
if the task is different one which i know (above) , then pls add description...
+ 2
#include <iostream>
using namespace std;
int main() {
int siblings, popsicles;
//take input
cin >> siblings >> popsicles;
//check for invalid input
if(popsicles <= 0) {
cout << "eat them yourself" << endl;
return 0;
}
else if(popsicles >= 2) {
cout << "give away" << endl;
return 0;
}
//calculate and output result
cout << popsicles % siblings << endl;
return 0;
}
+ 2
Thx btw i got it so:
#include <iostream>
using namespace std;
int main() {
int siblings, popsicles; cin >> siblings >> popsicles;
if (popsicles % siblings == 0) { cout << "give away" << endl;
} else {
cout << "eat them yourself" << endl;
}
return 0;
}
+ 1
But i did i have else if
+ 1
Should i do: else {
cout << "give away" << endl;
return 0;
}
+ 1
Thx
+ 1
👍
You're welcome..
0
С чем помочь?