-
Notifications
You must be signed in to change notification settings - Fork 61
/
Pattern11.java
42 lines (39 loc) · 887 Bytes
/
Pattern11.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.java.patterns;
import java.util.Scanner;
/*
Write a Java Program to print the following Pattern
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
*/
public class Pattern11 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the number of rows to print the pattern :: ");
int N = Integer.parseInt(scanner.nextLine().trim());
for(int i=0;i<N;i++){
for(int j=0;j<5;j++)
if(j == 4)
System.out.print((i+1)+"");
else
System.out.print(i+1+" ");
if(i < N-1)
System.out.println("");
}
scanner.close();
}
}
/*
OUTPUT
Enter the number of rows to print the pattern :: 5
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
Enter the number of rows to print the pattern :: 2
1 1 1 1 1
2 2 2 2 2
*/