중복값 없이 랜덤 출력하기 - 카드섞기 기법
자바 프로그래밍/코드 2020. 2. 12. 23:01

//중복값 없이 랜덤 출력하기 //이중루프를 이용하여 하는 방법도 있음(필터링로직) public class Exam_04 { public static void main(String[] args) { /* * System.out.println((int)(Math.random()*5+1)); // 1~5 * System.out.println((int)(Math.random()*5+1)); // 1~5 * System.out.println((int)(Math.random()*5+1)); // 1~5 * System.out.println((int)(Math.random()*5+1)); // 1~5 * System.out.println((int)(Math.random()*5+1)); // 1~5 */ // ctr..

배열과 스왑(swap)기법
자바 프로그래밍/코드 2020. 2. 12. 23:01

//두 문자 서로 바꾸기 public class Exam_03 { public static void main(String[] args) { char[] A = new char[2]; char tmp; A[0]='A'; A[1]='B'; System.out.println(""+A[0]+A[1]); tmp=A[0]; A[0]=A[1]; A[1]=tmp; System.out.println(""+A[0]+A[1]); } }

입출력과 배열
자바 프로그래밍/코드 2020. 2. 12. 23:00

import java.util.Scanner; public class Exam_02 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); /* System.out.print("1번째 수 : "); int num1= Integer.parseInt(sc.nextLine()); System.out.print("2번째 수 : "); int num2= Integer.parseInt(sc.nextLine()); System.out.print("3번째 수 : "); int num3= Integer.parseInt(sc.nextLine()); System.out.println("num1 : " + num1); System.out...

배열참조변수
자바 프로그래밍/코드 2020. 2. 12. 23:00

import java.util.Scanner; public class Exam_01 { public static void main(String args[]) { int a=10; //int[] arr; //arr이라는 변수만 만들어진 것, 정확히는 Stack에다가 "배열의 주소를 저장한 참조변수"를 만든 것임. 배열의 본체는 Heap에 있다. 주소값을 Stack에 만들어진 변수 arr이 갖고 있는 것. //Heap에다가 뭔가 새로 만들겠습니다, Heap을 이용하겠습니다 할때의 용법은 new //new int[5]; //int형 변수 5개를 Heap에 만들겠다는 의미 //int b = new int[5]; // 에러가 남. 자료형이 안맞음. //String b = new int[5]; //에러가 남. 마찬..

Baskin Robbins 31 Game
자바 프로그래밍/코드 2020. 2. 11. 18:07

import java.util.Scanner; //Baskin Robbins 31 Game //1부터 시작, 31이 될때까지 서로 턴을 교대하여 숫자를 증가 //31을 먼저 외치는 사람이 지는 게임 public class Quiz_03 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int menu; int win=0; //플레이어 승리 int lose=0; //플레이어 패배 int player_oppo=0; //플레이어 횟수 int computer_oppo=0; // 컴퓨터 횟수 int number=0; //숫자 int i=0; //for문용 int int button=0; //31 나왔을때 종료용 버튼 //..

경마 배팅 게임
자바 프로그래밍/코드 2020. 2. 11. 18:07

3마리의 말들이 각자 갖고 있는 기본능력치에 난수로 만들어진 각자의 컨디션상태를 더하여 오늘의 경기력을 만들었다. 승률이 높은 말은 배팅하였을때 배당금이 낮고, 승률이 낮은 말은 배팅하였을때 배당금이 높게 설정하였다. import java.util.Scanner; //경마 배팅 게임 public class Quiz_02 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int menu=0; //메뉴 int money=0; //충전하려는 금액 int account=0; //잔액 int choose_horse=0; //배팅하려는 말 선택기 int betting=0; // 배팅금액 int horse_a; //1번마 i..