Skip to main content

[Java] 컴퓨터랑 가위바위보(묵찌빠)

import java.util.*; // Scanner, Random 클래스 사용 class ExRandom3 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); Random rand = new Random(); String[] str = new String[] {”묵”, ”찌”, ”빠”}; // 서로 선택한게 뭔지 출력해주기 위해 int user, com; while(true) { System.out.println(”1. 묵, 2. 찌, 3. 빠, 0. 종료”); System.out.print(”선택? ”); […]

Read More

[Java] 로또번호생성기

import java.util.*; // Random 클래스를 사용하기 위해.. class ExRandom2 { public static void main(String[] args) { int[] lotto = new int[] {0, 0, 0, 0, 0}; // 로또번호 저장할 배열 int temp, i, j, index=0; // 로또번호정렬, 인덱스에 쓰일 변수 Random rand = new Random(); // 난수생성을 위해 Random클래스 객체생성 while(index<5) { lotto[index++] = rand.nextInt(45)+1; […]

Read More