U E D R , A S I H C RSS

Number Baseball Game/성재

~cpp  
#include<iostream>
#include<ctime>
using namespace std;

int main()
{
	int num;
	int strike=0;
	int ball=0;
                
    int rmatch[3];
	do
	{
	srand((time(0)));   
    rmatch[0] = rand() % 10;  
    srand((time(0)));   
    rmatch[1] = rand() % 10;
	rmatch[2] = rand() % 10;}
	while(rmatch[0]==rmatch[1] || rmatch[1]==rmatch[2] || rmatch[0]==rmatch[2]);
	cout << rmatch[0]<< rmatch[1]<< rmatch[2];

	cout<<"야구게임을 해 봅시닷! 수를 입력하세요. 단 세자리여야 합니다.\n" ;
	cin >> num;
	
	int match[3];
	match[0]=num/100;
	match[1]=(num%100)/10;
	match[2]=num%10;
	int check=0;

	if(num>100 && num<999)
	{
		for(int i=0;i<3&& check==0;i++)
		{
			for(int j=0;j<3 && check==0;j++)
			{
				if(i==j && match[i]==rmatch[j])
					strike++;
				else if(i!=j && match[i]==rmatch[j])
					ball++;
	
		}
	
		}
		if(strike==0 && ball==0)
		cout<<"out...\n";
		
		else
		{cout<< endl <<strike << ":스트라이크\n";
		cout<< ball << ":볼\n";}
}	
	else
	cout<<"다시 입력하셔야 겠네요~\n";
	return 0;
}
아아악~ 이거역시 어렵습니다아~ ㅜ_ㅜ  한참 고생해서 도움받고...에이구우~
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:52
Processing time 0.0127 sec