import java.util.Scanner;
public class Homework {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int a = (int)(Math.random()*10) ;
int b = (int)(Math.random()*10) ;
int c = (int)(Math.random()*10) ;
while ( a != b && b != c && a != c ) {
System.out.print("100자리의 숫자를 입력해주세요>");
int x = Integer.parseInt(sc.nextLine());
System.out.print("100자리 숫자를 제외하고 10자리 숫자를 입력해 주세요 >");
int y = Integer.parseInt(sc.nextLine());
System.out.print("100자리 숫자와 10자리 숫자를 제외하고 1자리 숫자를 입력해 주세요 >");
int z = Integer.parseInt(sc.nextLine());
do {
int st = 0;
int ba = 0;
int o = 0;
if ( x == a ) {
st += 1;
}else if ( x == b ){
ba += 1;
}else if ( x == c ){
ba += 1;
}else {
o += 1; }
if ( y == a ) {
ba += 1;
}else if ( y == b) {
st += 1;
}else if ( y == c ){
ba += 1;
}else {
o += 1; }
if ( z == a ) {
ba += 1;
}else if ( z == b ){
ba += 1;
}else if ( z == c ){
st += 1;
}else {
o += 1 ;}
System.out.print ( a , b , c + " : " + st + " strike " + "," + ba + " ball " + " " + o + "out" );
/* 질문 : a, b, c,가 숫자인데 얘를 그냥 나열하려면 항변환을 해주면 되나?
} while ( (a * 100 + b * 10 + c * 1) != (x * 100 + y * 10 + z * 1) );
}
}
}
댓글
댓글 쓰기