MagdalenaTakeva

PO8_MatrixNumbers2

Feb 15th, 2022
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. public class PO8_MatrixNumbers2 {
  2. public static void main(String[] args) {
  3. Scanner scanner = new Scanner(System.in);
  4. int n = Integer.parseInt(scanner.nextLine());
  5. String result = "";
  6.  
  7.  
  8. for (int i = 1; i <= n; i++) {
  9. int j;
  10. for (j = i; j <=n ; j++) {
  11. System.out.print(j + " ");
  12. }
  13. for (int k = i-1; k >=1; k--) {
  14. System.out.print(j + " ");
  15. j++;
  16.  
  17. }
  18. System.out.println();
  19. }
  20.  
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment