Day 4 :Class vs. Instance
Solution In Java 8:
import java.io.*;import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] arr = new int[n];
for(int i=0; i < n; i++){
arr[i] = in.nextInt();
}
for(int j = n-1;j >= 0;j--)
{
System.out.print(arr[j]+" ");
}
in.close();
}
}
Solution In Python 3:
import sys
n = int(input().strip())
arr = [int(arr_temp) for arr_temp in input().strip().split(' ')]
for i in range(n-1, -1, -1):
print(arr[i],end=" ")
0 comments:
Post a Comment