Output:
Click Here For Java Online Compiler
Solution:
Enter the number of rows: 5 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
Click Here For Java Online Compiler
Solution:
import java.util.Scanner; class NumberPattern5 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter the number of rows: "); int base = scanner.nextInt(); System.out.println(); for (int i = base; i > 0; i--) { for (int j = 1; j <= i; j++) { System.out.print(j + " "); } System.out.println(); } for (int i = 2; i <= base; i++) { for (int j = 1; j <= i; j++) { System.out.print(j + " "); } System.out.println(); } } }
comment 0 comments:
more_vertsentiment_satisfied Emoticon