/**
Pattern-44:
Enter N : 5
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
*/
import java.io.*;
public class Pattern44
{
public static void main(String args[])throws IOException
{
int i, j, k, n;
InputStreamReader read = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(read);
System.out.print("Enter N : ");
n=Integer.parseInt(in.readLine());
for(i=1;i<=n;i++)
{
for(j=1;j<=n-i;j++)
{
System.out.print(" ");
}
for(k=1;k<=i;k++)
{
System.out.print(k+" ");
}
System.out.println();
}
}
}
Pattern-44:
Enter N : 5
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
*/
import java.io.*;
public class Pattern44
{
public static void main(String args[])throws IOException
{
int i, j, k, n;
InputStreamReader read = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(read);
System.out.print("Enter N : ");
n=Integer.parseInt(in.readLine());
for(i=1;i<=n;i++)
{
for(j=1;j<=n-i;j++)
{
System.out.print(" ");
}
for(k=1;k<=i;k++)
{
System.out.print(k+" ");
}
System.out.println();
}
}
}
No comments:
Post a Comment