1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | package mypackage; public class WhileExample1 { public static void main(String[] args) { int cnt = 0; while (cnt < 10) { System.out.println(cnt); cnt++; } System.out.println("Done."); } } public class DoWhileExample1 { public static void main(String[] args) { int cnt = 0; do { System.out.println(cnt); cnt++; } while (cnt < 10); System.out.println("Done."); } } public class ForExample1 { public static void main(String[] args) { for (int cnt = 0; cnt < 10; cnt++) System.out.println(cnt); System.out.println("Done."); } } //<<<<<<<<<100까지 중에 짝수>>>>>>>>>> public class WhileExample1 { public static void main(String[] args) { int cnt = 0; while (cnt < 101) { System.out.println(cnt); cnt = cnt+2; } System.out.println("Done."); } } public class DoWhileExample1 { public static void main(String[] args) { int cnt = 0; do { System.out.println(cnt); cnt = cnt+2; } while (cnt < 101); System.out.println("Done."); } } public class ForExample1 { public static void main(String[] args) { for (int cnt = 0; cnt < 101; cnt = cnt+2) System.out.println(cnt); System.out.println("Done."); } } //<<<<<<<<<100까지 중에 4의 배>>>>>>>>>> public class WhileExample1 { public static void main(String[] args) { int cnt = 0; while (cnt < 101) { System.out.println(cnt); cnt = cnt+4; } System.out.println("Done."); } } public class DoWhileExample1 { public static void main(String[] args) { int cnt = 0; do { System.out.println(cnt); cnt = cnt+4; } while (cnt < 101); System.out.println("Done."); } } public class ForExample1 { public static void main(String[] args) { for (int cnt = 0; cnt < 101; cnt = cnt+4) System.out.println(cnt); System.out.println("Done."); } } | cs |
'개발' 카테고리의 다른 글
[java] for문 구구단 (0) | 2013.04.05 |
---|---|
[java] while문 구구단 (0) | 2013.04.05 |
[java] 지폐단위별 숫자 구하기2 (0) | 2013.04.04 |
[java] 지폐단위별 숫자 구하기 (0) | 2013.04.04 |
[java] 가위, 바위, 보 게임 (0) | 2013.04.04 |