프로그래밍 (11) 썸네일형 리스트형 [Java] 중복되지 않는 숫자만 배열에 집어넣고 싶은 사람만 보세요 public class Example { public static void main(String[] args) { int [] array = new int [10]; for(int i = 0; i < array.length; i++) { int r = (int) (Math.random() * 100 + 1); // 1~100 사이의 정수 만들기 array[i] = r; for(int j = 0; j < i; j++) // 현재 배열의 현재 인덱스 이전까지의 요소들을 검사 { if(array[j] == array[i]) { System.out.println("중복된 숫자가 나왔어요..."); // 체크용으로 일단 집어넣는다. i--; // 새 멤버가 들어있는 곳의 인덱스를 다시 사용하기 위해서 i를 1 뺀.. [Java] 윤년 계산하기 public class Example { public static void main (String [] s) { int year = 2000; boolean isLeapYear = false; if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0) { isLeapYear = true; } } } You can change the value of variable year. [Java] 입력된 숫자 두 개로 사칙연산 + 나머지 구하기 import java.util.Scanner; public class Example { public static void main (String [] s) { Scanner sc = new Scanner(System.in); System.out.print("첫 번째 숫자를 입력하세요"); int num1 = sc.nextInt(); System.out.print("두 번째 숫자를 입력하세요"); int num2 = sc.nextInt(); int result = 0; // add result = num1 + num2; System.out.println("result = " + result); // subtract result = num1 - num2; System.out.println("result = .. 이전 1 2 다음