Output:
Click Here For Java Online Compiler
Solution:
Enter the number of rows: 8 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 6 5 4 3 2 1 7 6 5 4 3 2 1 8 7 6 5 4 3 2 1
Click Here For Java Online Compiler
Solution:
import java.util.Scanner; class NumberPattern2 { 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(); int it = 1; for (int a = 1; a <= base; a++) { for (it = a; it >= 1; it--) { System.out.print(it + " "); } System.out.println(); } } }
comment 0 comments:
more_vertsentiment_satisfied Emoticon