Notes1:
package Pattern;
public class Training11 {
public static void main(String[] args) {
int no = 1;
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=6-row; col++)
{
System.out.print(no+" "); no++; // 1 2 3 4 5
}
System.out.println();
}
}
}
output:
1 2 3 4 5
6 7 8 9
10 11 12
13 14
15
Notes2:
package Pattern;
public class Training12 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=row; col++)
{
System.out.print(col+ " ");
}
System.out.println();
}
}
}
output:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Notes3:
package Pattern;
public class Training13 {
public static void main(String[] args) {
// TODO Auto-generated method stub
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=row; col++)
{
System.out.print(6-col+" "); // 1 2 3 4 5
}
System.out.println();
}
}
}
output:
5
5 4
5 4 3
5 4 3 2
5 4 3 2 1
Notes4:
package Pattern;
public class Training14 {
public static void main(String[] args) {
// TODO Auto-generated method stub
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=row; col++)
{
System.out.print(6-row+" "); // 1 2 3 4 5
}
System.out.println();
}
}
}
output:
5
4 4
3 3 3
2 2 2 2
1 1 1 1 1
Notes5:
package Pattern;
public class Training15 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col=1; col<=5; col++)
System.out.print(" ");
for(int col= 1; col<=6-row; col++)
{
System.out.print(row+col-1+" "); // 1 2 3 4 5
}
System.out.println();
}
}
}
output:
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
Notes6:
package Pattern;
public class Training16 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col=1; col<=row; col++)
System.out.print(" ");
for(int col= 1; col<=6-row; col++)
{
System.out.print(row+col-1+" "); // 1 2 3 4 5
}
System.out.println();
}
}
}
output:
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
Notes7:
package Pattern;
public class Training17 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col=1; col<=row; col++)
System.out.print(" ");
for(int col= 1; col<=6-row; col++)
{
System.out.print(col+" "); // 1 2 3 4 5
}
System.out.println();
}
}
}
output:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Notes8:
package Pattern;
public class Training18 {
public static void main(String[] args) {
for(int row=1; row<=5; row++){
for(int col= 1; col<=row-1; col++){
System.out.print( col +" ");
}
System.out.println();
}
}
}
output:
1
1 2
1 2 3
1 2 3 4
Notes9:
package Pattern;
public class Training19 {
public static void main(String[] args) {
for(int row=1; row<=5; row++){
for(int col= 1; col<row; col++)
{
System.out.print( col +" ");
}
for(int col=1; col<=10; col++)
System.out.print("* ");
System.out.println();
}
}
}
output:
1 * * * * * * * * * *
1 2 * * * * * * * * * *
1 2 3 * * * * * * * * * *
1 2 3 4 * * * * * * * * * *
Notes10:
package Pattern;
public class Training20 {
public static void main(String[] args) {
for(int row=1; row<=5; row++){
for(int col= 1; col<row; col++){
System.out.print( col +" ");
}
System.out.println("*");
System.out.println();
}
}
}
output:
*
1 *
1 2 *
1 2 3 *
1 2 3 4 *
Notes11:
package Pattern;
public class Training21 {
public static void main(String[] args) {
for(int row=1; row<=5; row++){
for(int col= 1; col<row; col++)
{
System.out.print( col +" ");
}
for(int col=1; col<=6-row; col++)
System.out.print("* ");
System.out.println();
}
}
}
output:
1 * * * *
1 2 * * *
1 2 3 * *
1 2 3 4 *
Notes12:
package Pattern;
public class Training22 {
public static void main(String[] args) {
for(int row=1; row<=5; row++){
for(int col= 1; col<row; col++)
{
System.out.print( col +" ");
}
for(int col=1; col<=6-row; col++)
System.out.print(col+row-1+" ");
System.out.println();
}
}
}
output:
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
Notes23:
package Pattern;
public class Training23 {
public static void main(String[] args) {
for(int row=1; row<=5; row++){
for(int col= 1; col<row; col++)
{
System.out.print( col +" ");
}
for(int col=1; col<=6-row; col++)
System.out.print(row+" ");
System.out.println();
}
}
}
output:
1 1 1 1 1
1 2 2 2 2
1 2 3 3 3
1 2 3 4 4
1 2 3 4 5
Notes24:
package Pattern;
public class Training24 {
public static void main(String[] args) {
// TODO Auto-generated method stub
for(int row=1; row<=5; row++){
for(int col= 1; col<row; col++)
{
System.out.print(" ");
}
for(int col=1; col<=6-row; col++)
System.out.print("* ");
System.out.println();
}
}
}
output:
* * * * *
* * * *
* * *
* *
*
Notes25:
package Pattern;
public class Training25 {
public static void main(String[] args) {
for(int row=1; row<=5; row++){
for(int col= 1; col<=6-row; col++)
{
System.out.print(" ");
}
for(int col=1; col<=row; col++)
System.out.print("* ");
System.out.println();
}
}
}
output:
*
* *
* * *
* * * *
* * * * *
Notes26:
package Pattern;
public class Training26 {
public static void main(String[] args) {
for(int row=1; row<=5; row++){
for(int col= 1; col<=6-row; col++)
{
System.out.print(" ");
}
for(int col=1; col<=row; col++)
System.out.print("* ");
System.out.println();
}
}
}
output:
*
* *
* * *
* * * *
* * * * *
Notes27:
package Pattern;
public class Training27 {
public static void main(String[] args) {
for(int row=1; row<=5; row++){
for(int col= 1; col<row; col++)
{
System.out.print(" ");
}
for(int col=1; col<=6-row; col++)
System.out.print("* ");
System.out.println();
}
}
}
output:
* * * * *
* * * *
* * *
* *
*
Top comments (0)