/**
Pattern-32:
Enter N : 5
1
1 4
1 4 9
1 4 9 16
1 4 9 16 25
*/
import java.io.*;
public class Pattern32
{
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=n;i>=1;i--)
{
for(j=1;j<i;j++)
{
System.out.print(" ");
}
for(k=1;k<=n-i+1;k++)
{
System.out.print(k*k+" ");
}
System.out.println();
}
}
}
Pattern-32:
Enter N : 5
1
1 4
1 4 9
1 4 9 16
1 4 9 16 25
*/
import java.io.*;
public class Pattern32
{
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=n;i>=1;i--)
{
for(j=1;j<i;j++)
{
System.out.print(" ");
}
for(k=1;k<=n-i+1;k++)
{
System.out.print(k*k+" ");
}
System.out.println();
}
}
}
No comments:
Post a Comment