I need to make an array in which I have to put 10 000 000 000 small numbers. I came to the fact that this is not possible.
The code is working if the place is LONG everywhere to put INT. But int does not fit this number of numbers. So, I will explain what I am doing in this code. I have a two-dimensional array, I need to sort it, it seems to me that the easiest way to do this is through a regular array, and based on that I had a problem with "10,000,000,000."
Is it possible to do this as I had planned, that is, without really changing the code? If not then ask for advice.
Difficult answers are not welcome because I just started programming and have little understanding of various functions.
int n = sc.nextInt(); int m = sc.nextInt(); if (n>=100000 || m>=100000) System.exit(0); int [][] array = new int [n][m]; long f =n*m; int [] arraypomoc = new int [n*m]; long poc =0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { array[i][j]=sc.nextInt(); arraypomoc[poc]=array[i][j]; poc++; } } for (long i = 0; i < arraypomoc.length-1; i++) { for (long j = 0; j < arraypomoc.length-i-1; j++) { if(arraypomoc[j]>arraypomoc[j+1]){ int temp = arraypomoc[j]; arraypomoc[j]=arraypomoc[j+1]; arraypomoc[j+1]=temp; } } }