Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. output now:-
  2. 0
  3. 1 2
  4. 3 4 5
  5. 6 7 8 9
  6.  
  7.  
  8.  
  9.  
  10.  
  11. // Array row column print..in 2D Diamontional new print..
  12.  
  13.  
  14. //initilize array create just row, not column
  15. int [][] num = new int[4][];
  16.  
  17.  
  18. //first row column declare..
  19. // 0 num row a column thakbe 1 ta.
  20. // 1 num row a column thakbe 2 ta.
  21.  
  22.  
  23. //row er under a column create, row num[0] a akta column new int[1]; create korlam.
  24. num[0] = new int[1];
  25. num[1] = new int[2];
  26. num[2] = new int[3];
  27. num[3] = new int[4];
  28.  
  29.  
  30. //initlize the value.
  31. int k = 0;
  32.  
  33. //create row with every looping 1 add to column with asign to num..
  34. for (int i =0; i<4; i++){
  35.  
  36. for (int j =0; j<i+1; j++){
  37.  
  38. // num asign korte hobe 1 , 1 kore barate hobe.
  39.  
  40. num[i][j] = k;
  41. k++;
  42. }
  43. }
  44.  
  45.  
  46.  
  47. // display show this array now...
  48. for (int i=0; i<4; i++){
  49.  
  50. for (int j=0; j<i+1; j++){
  51.  
  52. System.out.print(num[i][j]+" ");
  53. }
  54.  
  55. System.out.println();
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement