0
What is that do?
System.out.println("");
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.
+ 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...
+ 1
Thank you!
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();
}
}
0
Here is the problem. Somebody wrote the code, but I couldn't catch what exactly this line do in the problem.