CPP - Array _ For _ LottoGenerator 1.0
// Create a game Lotto
#include <iostream>
#include <time.h>
#include <iomanip>
using namespace std;
#define LOTTO 45
int main()
{
srand((unsigned int)time(0));
int iLotto[LOTTO] = {};
for (int i = 0; i < LOTTO; ++i)
{
iLotto[i] = i + 1;
}
// Shuffle
int iTemp, iIndex1, iIndex2;
int iRandomline;
for (int i = 0; i < LOTTO * 4; ++i)
{
iIndex1 = rand() % LOTTO;
iIndex2 = rand() % LOTTO;
// Swap
iTemp = iLotto[iIndex1];
iLotto[iIndex1] = iLotto[iIndex2];
iLotto[iIndex2] = iTemp;
}
for (int i = 0; i < LOTTO; ++i)
{
cout << setw(5) << iLotto[i];
if (i % 6 == 5)
cout << endl;
}
iRandomline = rand() % 7 + 1;
cout << "\n This week's winning number is ";
for (int i = 0; i < 6; ++i)
{
cout <<setw(5) << iLotto[iRandomline + i] ;
if (i == 5)
cout << "\n Service Number is " << iLotto[iRandomline + i + 1];
}
return 0;
}
'my_lesson > _C++' 카테고리의 다른 글
C++ - Array_For_BaseballGame Ver.1.0 (0) | 2019.04.05 |
---|---|
C++ - Array_For_LottoGenerator 1.1 (0) | 2019.04.05 |
CPP - Repeat While, RackPaperScissors_Game (0) | 2019.04.03 |
CPP - Condition If , Switch (0) | 2019.04.03 |
CPP - Operator (0) | 2019.04.03 |
댓글