1 条题解

  • 0
    @ 2023-6-11 12:20:56

    C :

    #include<stdio.h>
    
    void main(){
    	int i,n,g,s,b;
    	scanf("%d",&n);
    	
    	for(i=1;i<=n;i++){
    		g=i%10;
    		s=i/10%10;
    		b=i/100;
    		if(i%2==0&&(g==3||s==3||b==3||g==5||s==5||b==5)){
    			printf("%d\n",i);
    		}
    	}
    }
    

    C++ :

    #include<iostream>
    using namespace std;
    
    int main() {
    	int i,n,g,s,b;
    	cin>>n;
    	for(i = 1;i <= n;i++){
    		b = i / 100;
    		s = i / 10 % 10;
    		g = i % 10;
    		if((b==3||s==3||g==3||b==5||s==5||g==5)&&i%2==0){
    			cout<<i<<endl;
    		}
    	} 
    }
    

    Java :

    import java.util.Scanner;
    
    public class Main {
    
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		int n = sc.nextInt();
    		for(int i=1;i<=n;i++){
    			int g = i % 10;
    			int s = i / 10 % 10;
    			int b = i / 100;
    			if((g==3 || s==3 || b==3 || g==5 || s==5 || b==5) && i%2==0){
    				System.out.println(i);
    			}
    		}
    	}
    
    }
    

    Python :

    n = int(input())
    for i in range(1, n+1):
        bw = i // 100 % 10
        sw = i // 10 % 10
        gw = i // 1 % 10
        if (bw == 3 or sw == 3 or gw == 3 or bw == 5 or sw == 5 or gw == 5) and i % 2 == 0:
            print(i)
    
    
    • 1

    【入门】输出满足条件的整数4

    信息

    ID
    2616
    时间
    1000ms
    内存
    16MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者