Java Pattern
Java Pattern
1
1 2
1 23
1 234
1 2345
1 23456
1 234567
Java Program :
import java.util.Scanner;
System.out.println();
}
sc.close();
}
}
Output :
Pattern 2 :
1
2 2
3 33
4 444
5 5555
6 66666
7 777777
Java Program :
import java.util.Scanner;
System.out.println();
}
sc.close();
}
}
Output :
Pattern 3 :
1
1 2
1 23
1 234
1 2345
1 23456
1 234567
1 23456
1 2345
1 234
1 23
1 2
1
Java Program :
1. import java.util.Scanner;
2.
3. public class MainClass
4. {
5. public static void main(String[] args)
6. {
7. Scanner sc = new Scanner(System.in);
8.
9. //Taking rows value from the user
10.
11. System.out.println("How many rows you want in this pattern?");
12.
13. int rows = sc.nextInt();
14.
15. System.out.println("Here is your pattern....!!!");
16.
17. //Printing upper half of the pattern
18.
19. for (int i = 1; i <= rows; i++)
20. {
21. for (int j = 1; j <= i; j++)
22. {
23. System.out.print(j+" ");
24. }
25.
26. System.out.println();
27. }
28.
29. //Printing lower half of the pattern
30.
31. for (int i = rows-1; i >= 1; i--)
32. {
33. for (int j = 1; j <= i; j++)
34. {
35. System.out.print(j+" ");
36. }
37.
38. System.out.println();
39. }
40.
41. //Closing the resources
42.
43. sc.close();
44. }
45. }
Output :
Pattern 4 :
1 234567
1 23456
1 2345
1 234
1 23
1 2
1
Java Program :
1. import java.util.Scanner;
2.
3. public class MainClass
4. {
5. public static void main(String[] args)
6. {
7. Scanner sc = new Scanner(System.in);
8.
9. //Taking rows value from the user
10.
11. System.out.println("How many rows you want in this pattern?");
12.
13. int rows = sc.nextInt();
14.
15. System.out.println("Here is your pattern....!!!");
16.
17. for (int i = rows; i >= 1; i--)
18. {
19. for (int j = 1; j <= i; j++)
20. {
21. System.out.print(j+" ");
22. }
23.
24. System.out.println();
25. }
26.
27. //Closing the resources
28.
29. sc.close();
30. }
31. }
Output :
[quads id=5]
Pattern 5 :
7 654321
7 65432
7 6543
7 654
7 65
7 6
7
Java Program :
1. import java.util.Scanner;
2.
3. public class MainClass
4. {
5. public static void main(String[] args)
6. {
7. Scanner sc = new Scanner(System.in);
8.
9. //Taking rows value from the user
10.
11. System.out.println("How many rows you want in this pattern?");
12.
13. int rows = sc.nextInt();
14.
15. System.out.println("Here is your pattern....!!!");
16.
17. for (int i = 1; i <= rows; i++)
18. {
19. for (int j = rows; j >= i; j--)
20. {
21. System.out.print(j+" ");
22. }
23.
24. System.out.println();
25. }
26.
27. //Closing the resources
28.
29. sc.close();
30. }
31. }
Output :
Pattern 6 :
7
7 6
7 65
7 654
7 6543
7 65432
7 654321
Java Program :
1. import java.util.Scanner;
2.
3. public class MainClass
4. {
5. public static void main(String[] args)
6. {
7. Scanner sc = new Scanner(System.in);
8.
9. //Taking rows value from the user
10.
11. System.out.println("How many rows you want in this pattern?");
12.
13. int rows = sc.nextInt();
14.
15. System.out.println("Here is your pattern....!!!");
16.
17. for (int i = rows; i >= 1; i--)
18. {
19. for (int j = rows; j >= i; j--)
20. {
21. System.out.print(j+" ");
22. }
23.
24. System.out.println();
25. }
26.
27. //Closing the resources
28.
29. sc.close();
30. }
31. }
Output :
Pattern 7 :
7 654321
6 54321
5 4321
4 321
3 21
2 1
1
Java Program :
1. import java.util.Scanner;
2.
3. public class MainClass
4. {
5. public static void main(String[] args)
6. {
7. Scanner sc = new Scanner(System.in);
8.
9. //Taking rows value from the user
10.
11. System.out.println("How many rows you want in this pattern?");
12.
13. int rows = sc.nextInt();
14.
15. System.out.println("Here is your pattern....!!!");
16.
17. for (int i = rows; i >= 1; i--)
18. {
19. for (int j = i; j >= 1; j--)
20. {
21. System.out.print(j+" ");
22. }
23.
24. System.out.println();
25. }
26.
27. //Closing the resources
28.
29. sc.close();
30. }
31. }
Output :
Pattern 8 :
1 234567
1 23456
1 2345
1 234
1 23
1 2
1
1 2
1 23
1 234
1 2345
1 23456
1 234567
Java Program :
1. import java.util.Scanner;
2.
3. public class MainClass
4. {
5. public static void main(String[] args)
6. {
7. Scanner sc = new Scanner(System.in);
8.
9. //Taking rows value from the user
10.
11. System.out.println("How many rows you want in this pattern?");
12.
13. int rows = sc.nextInt();
14.
15. System.out.println("Here is your pattern....!!!");
16.
17. //Printing upper half of the pattern
18.
19. for (int i = rows; i >= 1; i--)
20. {
21. for (int j = 1; j <= i; j++)
22. {
23. System.out.print(j+" ");
24. }
25.
26. System.out.println();
27. }
28.
29. //Printing lower half of the pattern
30.
31. for (int i = 2; i <= rows; i++)
32. {
33. for (int j = 1; j <= i; j++)
34. {
35. System.out.print(j+" ");
36. }
37.
38. System.out.println();
39. }
40.
41. //Closing the resources
42.
43. sc.close();
44. }
45. }
Output :
Pattern 9 :
1
1 21
1 2321
1 2343 21
1 2345 4321
1 2345 654321
1 2345 67654321
Java Program :
1. import java.util.Scanner;
2.
3. public class MainClass
4. {
5. public static void main(String[] args)
6. {
7. Scanner sc = new Scanner(System.in);
8.
9. //Taking rows value from the user
10.
11. System.out.println("How many rows you want in this pattern?");
12.
13. int rows = sc.nextInt();
14.
15. System.out.println("Here is your pattern....!!!");
16.
17. for (int i = 1; i <= rows; i++)
18. {
19. //Printing first half of the row
20.
21. for (int j = 1; j <= i; j++)
22. {
23. System.out.print(j+" ");
24. }
25.
26. //Printing second half of the row
27.
28. for (int j = i-1; j >= 1; j--)
29. {
30. System.out.print(j+" ");
31. }
32.
33. System.out.println();
34. }
35.
36. //Closing the resources
37.
38. sc.close();
39. }
40. }
Output :
Pattern 10 :
1
2 1
3 21
4 321
5 4321
6 54321
7 654321
Java Program :
import java.util.Scanner;
System.out.println();
}
sc.close();
}
}
Output :