c++和Python解法如下
2025-07-22 11:02:05
发布于:上海
1阅读
0回复
0点赞
c++解法
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
for (int i = 0; i <= n; i++){
if(i % 3 == 2 && i % 5 == 3 && i % 7 == 2){
cout << i << endl;
}
}
return 0;
}
Python解法
a = int(input())
for i in range (a):
if i % 3 == 2 and i % 5 == 3 and i % 7 == 2:
print(i)
这里空空如也
有帮助,赞一个