java - How to change my logic to print numbers in jsp? -


Here my code is working fine but I need a sequence of elements in different order. This is my code.

  & lt; Body & gt; & Lt;% out.println ("& lt; Table & gt;"); Int apps = 9; Double row column = math.xtrt (app); (Double I = rowColumn; i> I--) {out.println ("& lt; tr & gt;"); (Double j = rowColumn; j & gt; 0; j--) {out.println ("> LD; TD>" + app + ""); Apps--; } Out.println ("& lt; / tr & gt;"); } Out.println ("& lt; / table & gt;"); & Gt%; & Lt; / Body & gt;   

Printing this value is as follows:

9 8 7

6 5 4

3 2 1

But I need the values ​​as follows:

7 8 9

6 5 4

1 2 3

If the apps = 16 then I need to put it out as follows:

16 15 14 13

9 10 11 12

8 7 6 5

1 2 3 4

How can someone change me?

Try it out, store values ​​in variables and print after loop: < Pre> & lt; Body & gt; & Lt;% out.println ("& lt; Table & gt;"); Int apps = 16; Double row column = math.xtrt (app); Boolean flag = true; (Double I = rowColumn; i>; i--) {string row content = ""; Out.println ("& lt; tr & gt;"); If flag (flag) flag flag; Other flag = true; (Double j = row column; j; gt; 0; j -) {if (flag) {rowContent = "& lt; td>; + Apps + "& lt; / td & gt;" + Row adjusted; } And {rowContent = rowContent + "& lt; TD & gt;" + Apps + "& lt; / td & gt;"; } //out.println("<td> "+ apps +" & lt; / td & gt; "); Apps--; } Out.println (rowContent); Out.println ("& lt; / tr & gt;"); } Out.println ("& lt; / table & gt;"); & Gt%; & Lt; / Body & gt;

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -