1 条题解
-
0
C :
#include<stdio.h> int main() { int i; for(i=1;i<=999;i++){ if(i%3==0&&((i%10==5)||(i/10)%10==5||(i/100)%10==5)) printf("%d\t",i); } }
C++ :
#include<iostream> #include<math.h> using namespace std; int main(){ int i,a,b,c,f = 0; for(i = 1;i <= 999;i++) { a = i / 100; b = i / 10 % 10; c = i % 10; if(i % 3 == 0){ if(a == 5 || b == 5 || c == 5){ cout<<i<<endl; } } } return 0; }
Python :
for n in range(1,1000): a=n//100 b=n//10%10 c=n%10 if n%3==0 and (a==5 or b==5 or c==5): print(n)
- 1
信息
- ID
- 95
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 0.004
- 标签
- 递交数
- 18
- 已通过
- 12
- 上传者