#include using namespace std;

int main() { int n; cin >> n;

for (int i = 1; i <= n; i++) {
    if (i % 10 == 5 || i % 10 == 8) {
        cout << i << endl;
    }
}

return 0;

}

c++【入门】输出个位为5或者个位为8数说明请从小到大输出1~n中所有个位为5或者个位为8的所有的整数每行1个。比如假设n=20那么满足条件的数输出如下:581518输入格式一个整数n。输出格式1~n中所有满足条件的整数。

原文地址: https://www.cveoy.top/t/topic/h4Ah 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录