1 solutions

  • 0
    @ 2025-3-3 16:33:15

    C :

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

    C++ :

    
    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
    	int i,n;
    	cin>>n;
    	for(i = 1;i <= n;i++){
    		if(i % 10 == 5 || i % 10 == 8){
    			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;
    			if(g==5 || g==8){
    				System.out.println(i);
    			}
    		}
    	}
    
    }
    

    Python :

    n = int(input())
    for i in range(1, n + 1):
        gw = i // 1 % 10
        if gw == 5 or gw == 8:
            print(i)
    
    
    • 1

    Information

    ID
    10549
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By