Python代码:输出1到n之间所有个位不为3的数字
"使用循环从1到n遍历每个数字,然后判断该数字的个位是否为3,如果不是,则输出该数字。\n\n以下是一个示例程序:\n\npython\ndef output_numbers(n):\n for i in range(1, n+1):\n if i % 10 != 3: # 判断个位是否为3\n print(i)\n\nn = int(input(\"请输入一个正整数n:\"))\noutput_numbers(n)\n\n\n这个程序会依次输出从1到n之间所有个位不为3的数字。\n
AI 优化版
原文地址:https://www.cveoy.top/t/topic/qh0e 著作权归作者所有。请勿转载和采集!