숫자 야구 게임

짜다 보니깐 현태꺼와 매우 흡사..ㅜㅜ


~cpp
import java.util.*;
public class game {

	public static void main(String[] args) {
		Random number = new Random(); 
		int[] arry = new int[3];
		int[] temp = new int[3];
		int strike=0;
		int ball=0;
		
		for(int i=0; i<3; i++)
		{
			arry[i]=number.nextInt(9);

		}
		System.out.println("입력:");
		while(strike!=3)
		{	
			strike=0;
			ball=0;
			
			Scanner scannumber = new Scanner(System.in);
			for(int i =0; i<3; i++)
			{
				temp[i]=scannumber.nextInt();
			}
			for(int i=0; i<3; i++)
			{
				if(arry[i]==temp[i])
					strike++;
				else for(int j=0; j<3; j++)
				{
					if(arry[i]==temp[j])
						ball++;
				}			
			}
		System.out.print("Strike=");
		System.out.print(strike);
		System.out.print("Ball=");
		System.out.println(ball);
		}
	}		
}
----
BasicJAVA2005, BasicJAVA2005/실습1
Retrieved from http://wiki.zeropage.org/wiki.php/BasicJAVA2005/실습1/송수생
last modified 2021-02-07 05:22:33