U E D R , A S I H C RSS

빵페이지/숫자야구

1.




DeleteMe . . ~cpp / .--NeoCoin


  • ~ -_ㅜ -
    • -
  • 4 ?? X ;; -
  • rand() .. .. -
    • ctime include 하 srane(time(0)); ~ -


2.

~cpp 
#include <iostream>
#include <stdlib.h> 
#include <time.h> 
using namespace std;
 int main()
{
	
	int num[3];
	while(num[0]==num[1] || num[1]==num[2] || num[0]==num[2])
	{
	srand(time(NULL)); 
   for(int i=0; i<3; i++)
      num[i] = rand()%9 +1; 
    }
	cout <<"  : " << num[0] << num[1] << num[2] << "\n";
	int ch; 
	while(ch) // 탈X  
	{cout <<" : ";
	cin >> ch;
	
	
	int person[3];
 	int bcount=0;
	int scount=0;
	person[0] = ch/100;
	person[1] = (ch%100)/10;
	person[2] = (ch%10);

		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
			if(num[i]==person[j])
				{
				if(i==j)
					scount++;
				else
					bcount++;
				}
			}
		}

		 if(scount==0 && bcount==0)
			cout << " : OUT\n";
		else if(scount==0 && bcount!=0)
			cout << " : "<< bcount << "\n";
		else if(bcount==0 && scount!=0)
		{	cout << " : " << scount << "크\n";
			if(scount==3)
				break;
		}
		else 
			cout << " : "<< scount << "크 " << bcount << "\n"; 
	}
		cout << " .\n";
		return 0;
	
}
.. -_-+
~ while .?

  • ,, ~ ㅋㅋ -
  • -_-;;; -
    • .ㅋㅋ


3.

~cpp 
//  .    4   9  .

#include <iostream.h>
#include <stdlib.h>
#include <time.h>

int main()
{
	int rand_num[3]; //  .
	int i, j, k, num;   //i,j,k , num   .
	int player_num[3];  //      rand_num   .
	int ext,extra;    // .
	int strike, ball; //  .
 
	srand(time(NULL));
 
	for(i=0;i<3;i++){
		rand_num[i] = rand()%10;   //한   .
		if (i == 1 && rand_num[i] == rand_num[0]) 
			i--;
		else if (i == 2 && (rand_num[i] == rand_num[0] || rand_num[i] == rand_num[1])) 
			i--;
	}          // if  통해 4    .
 
	for (i=0;i<9;i++){   // 
		cout << "3  (   ) : " ;
		cin >> num;
		ext = num;
  
		if (num < 100 || num > 999) {
			cout << "\a  .   . \n";
			i--;
		}
		else{
			for (j=2;j>=0;j--){//  
				player_num[j] = ext%10;
				ext = ext/10;
			}
			for(j=0;j<2;j++){  //  
				extra = 1;
				for(k=j+1;k<3;k++){
					if (player_num[j] == player_num[k]) {
						cout << "\a  .   . \n";
						i--;
						extra = 0;
						break;
					}
					if (extra == 0) break;
				}
				if (extra == 0) break;
			}   //   
		}    // else  
                  	if (extra == 0) continue;

		strike = 0;
		ball = 0;

		if (extra == 1) {
			for(j=0;j<3;j++){  
				for(k=0;k<3;k++){
					if (rand_num[j] == player_num[k] && j==k) strike++;
					if (rand_num[j] == player_num[k] && j!=k) ball++;
				}
			}
		}
		if (strike == 0 && ball == 0) cout << ".\n";
		else cout << strike << "크, " << ball << " .\n";
		if (strike == 3) {
			cout << " .!!\n";
			break;
		}
		if (i==8 && strike!=3) cout << "9회   .\n";
	}     //  
	return 0;
}
-_-;;; -


  • .. ..
    ㅜㅜ -

4.

~cpp 
#include<iostream> // 판 ^^
#include<ctime>
using namespace std;
int main()
{
	int num[3];
	int yagu[3];
	int a;
	cout<<"  :";
	srand(time(NULL));
	do
	{
	for(int i=0;i<3;i++)
	num[i]=rand()%9+1;
	}while(!(num[0]!=num[1] && num[1]!=num[2] && num[2]!=num[0]));
		cout<<num[0]<<num[1]<<num[2];
up :
	cout<<"\n:"; 
	cin>>a;
	if(a<1000 && a>99)
		{
			yagu[0]=a/100;
			yagu[1]=(a-yagu[0]*100)/10;
			yagu[2]=(a-yagu[0]*100-yagu[1]*10);
		}
	else
			cout<<" :";
	
	int strike=0;
	int ball=0;
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			if(yagu[i]==num[j])
			{
				if(i==j)
					strike++;
				if(i!=j)
					ball++;
			}
		}
	}
	if(strike!=0 && ball==0)
		if(strike==3)
			cout<<strike<<"크! ";
		else
		{cout<<strike<<"크";
		goto up;
		}
	else if(strike==0 && ball!=0)
	{
		cout<<ball<<"";
		goto up;
	}
	else if(strike!=0 && ball!=0)
	{
		cout<<strike<<"크"<<ball<<"";
		goto up;
	}
	else
	{
		cout<<"out";
		goto up;
	}
	return 0;
}

5. v1.3

~cpp 
#include <iostream.h>
#include <stdlib.h>
#include <ctime>
void game();
void new_game();


void main()
{
        cout << "┌┐\n" 
                "│                                                    │\n" 
                "│                                                    │\n" 
                "│                                            │\n" 
                "│                                                    │\n" 
                "│                          ver 1.3               │\n" 
                "│                                                    │\n" 
                "│                                                    │\n" 
                "│                                                    │\n" 
                "│                                  Made by     │\n" 
                "│                                                    │\n" 
                "└┘\n";// 	

         cout << "\n";

	game(); //  
}

void game()
{
	char random[4]; //     
	char space[64]; //    
	int strike = 0; //  화
	int ball = 0; //   화
	srand(time(NULL));
	
	for (int i = 0; i < 4; i++)	
	{	
		random[i] = '0' + rand() % 9 + 1;
        for (int j = 0; j < i; j++)
			if (random[i] == random[j])
			{
				i--;
				break;
			}
	} //  4  
	
	
	/*cout << random[0] << random[1] << random[2] << random[3] << endl;*/ //   -_-;;;


	cout << " 4 .  *^^* ( : Q)\n\n";
	
	int success = 0; //    (0 = 패, 1 = )

	while (success == 0)
	{	
		cout << "  : ";
		cin.getline(space, 64);
		success = 1;

		if ((space[0] == 'q' || space[0] == 'Q') && space[1] == '\0') 
		{
			cout << "Bye!!\n";
			exit(0);
		} //  'Q'  
		
		for (i = 0; i < 4; i++)
		{	
			if (space[i] < '1' || space[i] > '9') 
			{
				success = 0;
                break;
			}
		} // 1~9    
        if (space[4] != '\0')
			success = 0; // 4 확히 
		for (i = 0; i < 3; i++)
			for (int h = i + 1; h < 4; h++)
				if (space[i] == space[h])
				{	
					success = 0;
					break;
				} //   
		if (success == 0)
			continue; //   1   

		//    ...
		
		for (int j = 0; j < 4; j++)
		{
			if (space[j] == random[j])
				strike++; // 
			for (int k = 0; k < 4; k++)
				if (j != k && space[j] == random[k])
					ball++; //  
				else 
					continue;
				
		}
			
		if (strike == 0 && ball == 0)
		{
			cout << " : ";
			cout << "OUT!!";	// 크,    'OUT' 		
		}
		else if (strike == 4)
			new_game(); // 확히   new_game함 
		else
		{
			cout << " : ";
			cout << strike << "S" << "  " << ball << "B";
		} //   
		
		cout << endl;
		
		strike = 0;
		ball = 0; 
		success = 0; // success 0 화함 while  
	}
}


void new_game() //    
{	
	cout << ". ? (Y/N) : ";
	char ch;
	cin >> ch;
	
	while (ch != 'y' || ch != 'Y' || ch != 'n' || ch != 'N')
	{
		if (ch == 'y' || ch == 'Y')
		{
			while (cin.get() != '\n')
				continue; // y      
			game();
			break;
		}
		else if (ch == 'n' || ch == 'N')
		{	
			cout << "Bye!!\n";
			exit(0); //  
		}
		else
		{
			cout << ". ? (Y/N) : ";
			cin >> ch; 
		}
	}
}


/*
Ver 1.3 Update
   

Ver 1.2 Update
  (  ㅜㅜ)

Ver 1.1 Update
3 4 .   .

Ver 1.0
  .           -_-;;;
*/

효... ㅜㅜ
.
...
!!!!!!!!!!
.
,
.

P.S. ... () C++ ~_~
Digi-VM

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:38
Processing time 0.0523 sec