1 solutions

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

    C :

    #include <stdio.h>
    #include <stdlib.h>
    
    /* run this program using the console pauser or add your own getch, system("pause") or input loop */
    /*给你m个整数,将其逆序输出
    输入
    
    第一行一个整数m(3 <= m <= 100 ):数的个数 第二行m个整数(空格隔开)(这些数在0-9999999之间)
    输出
    
    m个整数(空格隔开*/
    void  main(int argc, char *argv[]) {
    	int a[100];
    	int m,i;
    	scanf("%d",&m);
    	
    	for(i=0;i<m;i++){
    		scanf("%d",&a[i]);
    		
    	}
    	for(i=m-1;i>=0;i--){
    		printf("%d ",a[i]);
    	}
    	
    	return 0;
    }
    

    C++ :

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main(){
        int a[100];
        int n,i;
        cin>>n;
        for(i=0;i<n;i++){
        	cin>>a[i];
    	}for(i=n-1;i>=0;i--){
    		cout<<a[i]<<" ";
    	}
        return 0;
    }
    

    Python :

    m = int(input())
    li = list( map(int,input().split()));
    li.reverse() 
    for x in li:
      print(x,end=' ')
    
    • 1

    Information

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