java - How to input integer 2d array fast -


I should be at the time the means, execution of input 5 AR arrays in less than 3G seconds 3, and I Using the scanner class or that, but it is making execution time more, so there is no other possible way, I must get input as

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  

And have to input 1 2 3 in a row? How do I do this ..? I was initially taking string as input, and then dividing it by using the partition ("") method, doing parsing using wrapper classes? Any other way to do this?

Try following snippet, I think you split the string using the scanner Do you want to Input the 2d array without

  int [] [] array = new int [5] [2]; Scanner scan = new scanner (System.in); Int i = 0; Int k = 0; While (scan.hasNextInt ()) {array [i] [k] = scan.nextInt (); K ++; If (k == 2) {k = 0; I ++; } If (i == array.length) {break; }} For (int p = 0; p & lt; array.length; p ++) {for (int j = 0; j & lt; 2; j ++) {system.out.print (array [p] ] [J] + ""); }}  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -