i want to print number pattern like this..
1
212
32123
4321234
but, i failed to get this triangle shape,and i am confused how to put spaces to get this shape-->
Here's the code i tried so far
public class Ch {
public static void main(String[] args) {
int r =Integer.parseInt(args[0]);
for(int u=1;u<=r;u++)
{
for(int i=u;i>=1;i--)
{
System.out.print(i);
}
for(int i=2;i<=u;i++)
{
System.out.print(i);
}
System.out.println();
}
}
output of this code looks-like this
1
212
32123
4321234
Thanks
Aucun commentaire:
Enregistrer un commentaire