10번
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 | package Pack01; import java.util.concurrent.SynchronousQueue; public class Hello { public static void main(String[] args) { //alt shift r 같은단어 바꾸기 if(true) { System.out.println("호랑이1"); } // if(true) { System.out.println("호랑이1"); }else { System.out.println("호랑이2"); } // if(false) { System.out.println("호랑이1"); }else if(true) { System.out.println("호랑이2"); }else if(true){ System.out.println("호랑이3"); }else { System.out.println("호랑이4"); } int a; /*if(3>2) { a=100; }else { a=200; }*/ a= 3>2?100:200; System.out.println(a); } } | cs |
11번
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 | package Pack01; import java.util.concurrent.SynchronousQueue; public class Hello { public static void main(String[] args) { //alt shift r 같은단어 바꾸기 for (int i = 0; i < 10; i++) { System.out.println(i); }System.out.println();//줄바꿈은 뒤에 그대로써서 한줄을 아낀다. for (int i = 0; i < 10; i++) { System.out.print(i + " "); }System.out.println(); System.out.println(); for (int i = 0; i < 10; i++) { System.out.println("5 * "+i +" "+"="+" "+i*5 ); }System.out.println(); int sum=0; for (int i = 1; i <= 10; i++) { sum+=i; } System.out.println(sum); for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { //System.out.print("( "+i+" "+j+" )"); System.out.printf("(%d %d)",i,j); } System.out.println(); } } } | cs |
12번
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 | package Pack01; import java.util.concurrent.SynchronousQueue; public class Hello { public static void main(String[] args) { //alt shift r 같은단어 바꾸기 int n =10; switch(n) { case 10 : System.out.println("새"); break; case 20 : System.out.println("독수리"); break; case 30 : System.out.println("앵무새"); break; default : System.out.println("끝"); break; }//switch ctrl space /*switch (key) { case value: break; default: break;*/ } } | cs |
12-1번
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | package Pack01; import java.util.concurrent.SynchronousQueue; public class Hello { public static void main(String[] args) { //alt shift r 같은단어 바꾸기 int a=0; while(true) { System.out.println(a++); if(a>10) { System.out.println("프로그램을 종료합니다."); break; } } } } | cs |
12-2번
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | package Pack01; import java.util.concurrent.SynchronousQueue; public class Hello { public static void main(String[] args) { //alt shift r 같은단어 바꾸기 int a=0; while(true) { System.out.println(a); a++; if(a>10) { break; } if(a%2==0) {//짝수라면 System.out.println(a+"continue"); continue; } } } } | cs |
12-3번
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | package Pack01; import java.util.concurrent.SynchronousQueue; public class Hello { public static void main(String[] args) { //ctrl shift r 같은단어 바꾸기 int n=27; while(true) { if(n==1) break; /*if(n%2==0) { n=n/2; } else { n=n*3+1; } */ n=(n%2==0)?n/2:n*3+1; System.out.println(n); } } } | cs |
728x90
'비트 단기 > java' 카테고리의 다른 글
24~ 31 (0) | 2018.11.29 |
---|---|
java class 2 17~24 (0) | 2018.11.28 |
java class시작 (0) | 2018.11.27 |
java 1 (0) | 2018.11.26 |
java설치 최신 , 환경변수 이클립스 (0) | 2018.11.26 |
댓글