提交时间:2024-11-09 10:00:53

运行 ID: 56077

#include <iostream> using namespace std; int digitSum(int num) { int sum = 0; while (num > 0) { sum += num % 10; num /= 10; } return sum; } int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { if (digitSum(i) % 2 == 0) { cout << i << " "; } } cout << endl; return 0; }