I want make code in which we have to add inputs and it show output at very after all inputs are performed. But i don't know how can i access the contents of variable in for loop in outer side.
My code is given below
import java.util.Scanner;
public class App {
public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
int T=sc.nextInt(); //How many Input case?
for(int i=0;i<T;i++)
{
int N=sc.nextInt(); //How many items in each cases?
for(int j=0;j<N;j++)
{
int C=sc.nextInt(); //How much cost of each items?
}
}
int [][]A =new int[T][N];
//I know here No issue with T but how can i acces N and C?
//here code to show output of given inputs.....
....
..
}
}
Ex:-
Input:--
2 //test cases
3 //items
1 2 3 //costs
4 //items
1 2 3 4 //costs
Ouput:---perfectly as in input.