java - Scanner not taking input properly -
public static void main(string[] args) { int t = sc.nextint(); (int = 1; <= t; i++) { int xs ; int n = sc.nextint(); int divisor = 1; (int j = 0; j < n -1;j++){ divisor = divisor * 10; } //system.out.println(divisor + "/" + n); int[][] matrix = new int[n][n]; int[][] matrix2 = new int[n][n]; (int k = 0; k < n; k++) { int d2 = divisor; xs = sc.nextint(); system.out.println(xs); // system.out.println("\n"+xs + "df" + xs.length()); (int l = 0; l < n; l++) { matrix[k][l] = xs / d2; matrix2[k][l] = 0; xs = xs % d2; divisor = d2/10; } } // system.out.println("hello"); matrix2[0][0] = 1; node node = new node(0, 0); node.dis = 0; node.steps = 0; node.c = 0; openlist[0] = node; util_expl(node, matrix, matrix2, n); fun(matrix, matrix2, n); system.out.println(res); } }//
my input example is
1
4
0100
1110
1011
1010
scanner getting stuck cant take input properly. paste whole input @ once printing line check whether input correct answer 100
1110
1010
getting stuck.
because start 1 , using nextint();
working example :
scanner sc = new scanner(system.in); system.out.println("type how many values : "); int t = sc.nextint(); string []a = new string[t] ; (int = 0; < t; i++) a[i] = sc.next(); (string item : a) system.out.println(item);
Comments
Post a Comment