0

What is that do?

System.out.println("");

3rd Jun 2017, 1:01 PM
gogamid
6 Respostas
+ 3
you finished half the Java course and don't know that System.out.println(""); writes a single line of text to the console? either you're trolling for badges or you skipped through the course... both would be very sad.
3rd Jun 2017, 1:06 PM
Mario L.
Mario L. - avatar
+ 2
it prints a blank line to the console. the program asks you for a number t. then the loop goes t times. in the loop you're asked for three numbers a, b and n. there's another loop which runs n times and prints the result of a + 2^j * b plus a space to the console. each result in the same line. after the loop the blank line to get a new line and the first loop begins again...
3rd Jun 2017, 1:46 PM
Mario L.
Mario L. - avatar
+ 1
Thank you!
3rd Jun 2017, 1:49 PM
gogamid
0
class Solution{ public static void main(String []argh){ Scanner in = new Scanner(System.in); int t=in.nextInt(); for(int i=0;i<t;i++){ int a = in.nextInt(); int b = in.nextInt(); int n = in.nextInt(); for(int j = 0; j < n; j++){ a = a + (int)Math.pow(2,j)*b; System.out.print(a + " "); } System.out.println(""); } in.close(); } }
3rd Jun 2017, 1:36 PM
gogamid
0
Here is the problem. Somebody wrote the code, but I couldn't catch what exactly this line do in the problem.
3rd Jun 2017, 1:37 PM
gogamid