You are viewing a single comment's thread. Return to all comments →
JAVA-
import java.util.Scanner; public class Solution{
public static void reverse(int num[]){ int start=0; int end =num.length-1; while(start<end){ int temp=num[end]; num[end]= num[start]; num[start]= temp; start++; end--; } } public static void main(String[]arg){ Scanner sc = new Scanner(System.in); int size = sc.nextInt(); int num[]=new int[size]; for(int i=0; i<size; i++){ num[i]=sc.nextInt(); } reverse(num); for(int i=0; i<num.length;i++){ System.out.print(num[i]+" "); } sc.close(); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Day 7: Arrays
You are viewing a single comment's thread. Return to all comments →
JAVA-
import java.util.Scanner; public class Solution{
}