Skip to content

Instantly share code, notes, and snippets.

@Vimalraj571
Created November 3, 2021 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vimalraj571/a1b89a078e70ca9725af6f07e6393d84 to your computer and use it in GitHub Desktop.
Save Vimalraj571/a1b89a078e70ca9725af6f07e6393d84 to your computer and use it in GitHub Desktop.
Reading the input for the java
// Reading from the coding platform for following line
// 3 - Test case
// 4 1 2 3 4 [4 - Array Length, 1 2 3 4 - Elements in array]
// 3 1 1 1 [3 - Array Length, 1 1 1 1 - Elements in array]
// 2 1 3 [2 - Array Length, 1 3 - Elements in array]
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
int[] outputArr;
int testCase;
Scanner sc = new Scanner(System.in);
testCase = sc.nextInt(); // Testcases
for (int i = 0; i < testCase; i++) {
while(sc.hasNextInt()){ // Until Next Line
int tempArrN = sc.nextInt();// Getting the array Length value
int[] inputArr = new int[tempArrN]; // Making the int array
for(int j=0;j<tempArrN;j++){// Loop till n
int temp = sc.nextInt();// Get the current value
inputArr[j] = temp; // set it in inputArr
}
for(int k=0;k<tempArrN;k++){
System.out.println(inputArr[k]); // Printing the array elements
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment