Solutions:
0, 21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294, 315, 320, 336, 340, 341, 357, 359, 360, 361, 362, 378, 378, 379, 380, 381, 382, 383, 397, 398, 399, 399.
1 2 3 4 5 6 7 8 9 10
|
while (x < 400)
{
if(x/20 == x%20)
cout << x << ", ";
if(x/20 + x%20 > 35)
cout << x << ", ";
if(x/20 - x%20 > 15)
cout << x << ", ";
x++;
}
|
:)
in real life, if you divide any number less than 20 by 20, you will get 0.xxxx. Since you are using an integer, you will get a whole number which will NOT be rounded up; c++ just drops off the digits.
in this case
1 2
|
int x = 1
cout << x/20;
|
the remainder (%) operator example:
1 2
|
int x = 43
cout << x/20;
|
20 can fit in 43 two times to give you 40
and what remains is 43-40 which in this case is 3