본문 바로가기

728x90
반응형

전체 글

(187)
[자바] 정올 127 : 반복제어문1 - 형성평가3 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int i, sum=0, count = 0; while(true){ i = sc.nextInt(); if(!(i >= 0 && i
[자바] 정올 126 : 반복제어문1 - 형성평가2 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int even = 0; int odd = 0; int i; while(true){ i = sc.nextInt(); if(i==0) break; if(i % 2 == 0) even++; else odd++; } System.out.println("odd : " + odd); System.out.println("even : " + even); } }
[자바] 정올 125 : 반복제어문1 - 형성평가1 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); for(int i = 1; i
[자바] 정올 633 : 반복제어문1 - 자가진단6 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int i; boolean a = true; while(a){ System.out.print("1. Korea\n" + "2. USA\n" + "3. Japan\n" + "4. China\n" + "number? "); i = sc.nextInt(); switch(i){ case 1: System.out.println("\nSeoul"); break; case 2: System.out.println("\nWashington"); break; case 3: System.out.printl..
[자바] 정올 540 : 반복제어문1 - 자가진단5 import java.util.Scanner; public class Main { public static void main(String[] args) { int i; Scanner sc = new Scanner(System.in); while(true){ i = sc.nextInt(); if(i == -1) break; if(i % 3 == 0) System.out.println(i/3); } } }
[자바] 정올 539 : 반복제어문1 - 자가진단4 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int i, sum = 0, count = 0; while(true){ i = sc.nextInt(); sum += i; count++; if(i >= 100) break; } System.out.printf("%d\n%.1f", sum, (double)sum / count); } }
[자바] 정올 538 : 반복제어문1 - 자가진단3 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a; while(true){ System.out.print("number? "); a = sc.nextInt(); if(a == 0) break; if(a > 0) System.out.println("positive integer"); else System.out.println("negative number"); } } }
[자바] 정올 537 : 반복제어문 - 자가진단2 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int i = 1; int sum = 0; while(i

728x90
반응형