CPP - Array_For_LottoGame Ver 1.2 functional
안녕하세요,
다음 링크를 클릭해 회의에 참가하십시오:
https://go.teamviewer.com/v14/m68206362
회의 ID: m68-206-362
Time : PM 23~24
감사합니다.
boolean
// Create a Game Lotto
// 1. 선택되서 출력되는 로또 번호를 오름차순으로 정렬해보자
// 2. 사용자가 선택한 번호와 추첨번호가 일치하면 Congratulation 을 출력하게 하자
#include
#include
#include
using namespace std;
#define LOTTO 45
#define LSIX 6
typedef enum {
FORTH = 3,
THIRD,
SECOND,
FIRST
}GRADE;
void SetNum(int iArr[], int iLotto[]);
void PrintNumOfLotto(int iArr[]);
void SortNum(int iArr[]);
void PrintNum(int iArr[]);
int CompareNum(int iuArr[], int iaArr[], int &iCnt);
void PrintWinningGrade(int iCnt);
int main()
{
srand((unsigned int)time(0));
int iLotto[LOTTO] = {}, iuInput[LSIX] = {}, iaInput[LSIX] = {};
int iCnt = 0;
int *pCnt = &iCnt;
// USER Input
SetNum(iuInput, iLotto);
// AI Input
SetNum(iaInput, iLotto);
// Print number of Lotto
PrintNumOfLotto(iLotto);
// Sort User Number
SortNum(iuInput);
// Sort Ai Number;
SortNum(iaInput);
// Print User's number
cout << "\nYour number is ";
PrintNum(iuInput);
// Print Winning number
cout << "\nAI number is ";
PrintNum(iaInput);
// Compare iuInput & iaInput
CompareNum(iuInput, iaInput, *pCnt);
// Print Winning Grade
PrintWinningGrade(iCnt);
return 0;
}
// Set Number
void SetNum(int iArr[], int iLotto[])
{
// Asignment User Number
for (int i = 0; i < LOTTO; ++i)
{
iLotto[i] =( i + 1);
}
//Shuffle Lotto Number
int iTemp, iIdx1, iIdx2;
for (int i = 0; i < LOTTO * 4; ++i)
{
iIdx1 = rand() % 45;
iIdx2 = rand() % 45;
iTemp = iLotto[iIdx1];
iLotto[iIdx1] = iLotto[iIdx2];
iLotto[iIdx2] = iTemp;
}
// Set Six Number
for (int i = 0; i < LSIX; ++i)
{
iArr[i] = iLotto[i];
}
}
// Print number of lotto
void PrintNumOfLotto(int iArr[])
{
for (int i = 0; i < LOTTO; ++i)
{
cout << setw(5) << iArr[i];
if (i % 6 == 5)
cout << endl;
}
}
// Sort Number
void SortNum(int iArr[])
{
for (int i = 1; i < LSIX; ++i)
{
for (int j = 0; j < i + 1; ++j)
{
if (iArr[j] > iArr[i])
{
int iTemp = iArr[j];
iArr[j] = iArr[i];
iArr[i] = iTemp;
}
}
}
}
// Print Number
void PrintNum(int iArr[])
{
for (int i = 0; i < LSIX; ++i)
{
cout << setw(5) << iArr[i];
}
}
// Compare Number
int CompareNum(int iuArr[], int iaArr[], int &iCnt)
{
cout << endl;
for (int i = 0; i < LSIX; ++i)
{
if (iuArr[i] == iaArr[i])
{
++iCnt;
}
}
return iCnt;
}
// Print Winning Grade
void PrintWinningGrade(int iCnt)
{
switch (iCnt)
{
case FORTH:
cout << "\n Your Grade is " << FORTH;
break;
case THIRD:
cout << "\n Your Grade is " << THIRD;
break;
case SECOND:
cout << "\n Your Grade is " << SECOND;
break;
case FIRST:
cout << "\n Your Grade is " << FIRST;
cout << "\nCongratulation !!\n";
break;
default:
cout << "We are sorry, but next time ~";
}
cout << "\nCorrect number of count : " << iCnt << " EA";
}
Cannot open include file: "Python.h": No such file or directory
//project -> Properties -> C/C++ -> General -> Addiational Include Direcrtories -> Add c:/Anaconda/include
'my_lesson > _C++' 카테고리의 다른 글
C++ - For 반복문 별그리기 ver 1.0 , ver 1.1 (0) | 2019.04.24 |
---|---|
C++ - Embeding Python3.7.3 in CPP project (0) | 2019.04.16 |
C++ - Array_For_BaseballGame Ver.1.0 (0) | 2019.04.05 |
C++ - Array_For_LottoGenerator 1.1 (0) | 2019.04.05 |
CPP - Array _ For _ LottoGenerator 1.0 (0) | 2019.04.04 |
댓글