Greater than 0, integers, not divisible by 7, less than N, please output all possible numbers.
Sample Inputs/Outputs
Sample Input(s) | Sample Output(s) |
---|---|
EOF inputs: each line contains an integer N, where N is no greater than 10000. If N = 0, it indicates the end of the input data. | The output should be as described earlier, with each number separated by a single space. |
5 10 20 0 | 1 2 3 4 1 2 3 4 5 6 8 9 1 2 3 4 5 6 8 9 10 11 12 13 15 16 17 18 19 |
Thought Process
Use a for loop to iterate through the numbers, and check if the current number is divisible by 7. If it's not, output the number; otherwise, continue to the next iteration.
Sample Code-ZeroJudge A147: Print it all
#include <iostream>
using namespace std;
int main() {
int N;
while (cin >> N)
{
if (N == 0) break;
else
{
for (int i = 1; i<N; i++)
{
if (i % 7 != 0) cout << i << " ";
}
}
cout << "\n";
}
}
//ZeroJudge A147
//Dr. SeanXD