U E D R , A S I H C RSS

숫자야구/민강근

~cpp 

#include <iostream>
#include <ctime>
using namespace std; 
 
int main() 
{ 
    srand(time(0));
                    
    int x = rand() % 1000; 
    int input,a,b,c,i,j,q,st,ba;
		
	cout<<"3개의 야구게임 : ___\b\b\b";
	cin>>input;

	a = input/100;
	b = input/10%10;
	c = input%10;

	i = x/100;
	j = x/10%10;
	q = x%10;
	
	do{
	st = 0;
	ba = 0;

	if(a == i)
		st++;
	if(a == j || a == q)
		ba++;
	if(b == j)
		st++;
	if(b == a || b == q)
		ba++;
	if(c == q)
		st++;
	if(c == i || c == j)
		ba++;
	
	cout<<st<<"스트라이크 "<<ba<<"볼 입니다."<<endl;
	cout<<"다시 입력해주세염 : ___\b\b\b";
	cin>>input;

	a = input/100;
	b = input/10%10;
	c = input%10;

	}while(input!=x);

	cout<<"home run!!";
		
	return 0; 
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:15
Processing time 0.0073 sec