1
12
123
1234
12345
123456
1234567
12345678
123456789
12345678910
berikut code java nya :
public class for1
{
public static void main (String args[])
{
int a,b;
for(a=1;a<=10;a++)
{
for(b=1;b<=a;b++)
{
System.out.print(b+"");
}
System.out.println("");
}
}
untuk menampilkan output seperti ini :
12345678910
123456789
12345678
1234567
123456
12345
1234
123
12
1
berikut code java nya :
public class for2
{
public static void main (String args[])
{
int a,b;
for(a=10;a>=1;a--)
{
for(b=1;b<=a;b++)
{
System.out.print(b+"");
}
System.out.println("");
}
}
}

0 comments:
Post a Comment