m = input("请输入m:") n = input("请输入n:") if not m.isdigit() or not n.isdigit(): print("error") else: m = int(m) n = int(n) count = 0 for num in range(m, n+1): if num % 3 == 2 and "6" in str(num): count += 1 print(f"在区间[{m}, {n}]上,除三余2且含6的数字有{count}个。")

用python写一段统计mn上除三余2且含6的数字mn由键盘输入输入无效数据时输出error的代码

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

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