loop
package sas;
public class a {
public static void main (String [] args) {
int MAX = 15;
/ / int i;
int i = 0, j = 1, k = 1;
while (k <= MAX) {
System.out.print ("" + i + "" + j);
i = i + j;
j = i + j;
k = k +2;
}
/ / System.out.println ();
}
}
------ Solution ------------------------------------ --------
number is behind the front two numbers
------ Solution -------------------- ------------------------
each line of output not to clear
------ Solution ------ --------------------------------------
while (k <= MAX) {
System.out.print ("" + i + "" + j);
i = i + j; / / If the start i = 1 j = 3 then i = i + j i = 4 after it. The following is the same.
j = i + j;
k = k +2;
}
------ Solution --------------------------------- -----------
while (k <= MAX) { / / When k <= 15 the following statement is executed
System.out.print ("" + i + "" + j); ;
i = i + j; / /
j = i + j;
k = k +2; / / for k +2 operations performed . K = 3 the first cycle , the cycle has to judge K. .. K> 15 out of the loop
}
------ For reference only ------------------------------- --------
can you explain the meaning of each of three lines do ?
------ For reference only -------------------------------------- -
i = i + j means that the i + j and i deposited
behind the same solution
------ For reference only ------------------------------- --------
while ( loop condition ) { loop body } first determine k is less than MAX, less than the loop will execute the code
------ For reference only --- ------------------------------------
Thank you , I look at understanding ;
没有评论:
发表评论