- 【入门】输出是2的倍数,但非3的倍数的数
y001p37 输出是2的倍数,但非3的倍数的数 你们是怎么做的
- 2025-1-5 11:31:50 @
n=int(input())
i=2
while i<=n:
if i%2==0 and i%3!=0:
print(i)
i=i+2
else:
i=i+2
4 条评论
-
张柏然 @ 2025-6-17 20:32:45
n = int(input()) for num in range(1, n + 1): if num % 2 == 0 and num % 3 != 0: print(num)
-
2025-3-24 22:08:25@
验证完成 答案正确
-
2025-2-23 19:56:42@
c++:
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ if(i%2==0 and i%3!=0){ cout<<i<<endl; } } return 0; }`
👍 1🍋 1 -
2025-1-5 11:32:32@
n=int(input()) i=2 while i<=n: if i%2==0 and i%3!=0: print(i) i=i+2 else: i=i+2
- 1
信息
- ID
- 85
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 4
- 标签
- 递交数
- 32
- 已通过
- 18
- 上传者