Segitiga Angka
public class segitiga_angka {
public static void main (String args []) {
String a="";
for (int i=1; i<=4; i++) {
a=a+i;
System.out.println(a);
}
}
}
Hasil :
1
12
123
1234
Trapesium
public class trapesium {
public static void main (String[] args) {
int baris;
baris=3;
for (int i=1; i<=baris; i++) {
for (int j=1; j<=4; j++) {
if (i<=j)
System.out.print("1");
else
System.out.print(" ");
}
System.out.println();
}
}
}
Hasil :
1111
111
11
Triagle Number
public class triangle_num {
public static void main(String args[]) {
for (int i=1; i<=5; i++) {
for (int j=1; j<=5-i; j++) {
System.out.print(""+j);}
System.out.println();
}
}
}
Hasil :
1234
123
12
1
Google search
Custom Search
Monday, November 14, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment