【題目敘述】https://zerojudge.tw/ShowProblem?problemid=a147
#include <iostream>
using namespace std;
int main() {
int n;
while (cin >> n && n) {
for (int i = 1; i < n; i++) {
if (i % 7 != 0) {
cout << i << " ";
}
}
cout << "\n";
}
return 0;
}
Python code (credit: Amy Chou)
while True:
s = input()
if s == '0':
break
result = ''
for i in range(1, int(s)):
if i % 7 != 0:
result += str(i) + ' '
print(result[:-1])