📄 lottoryutils.cpp
字号:
// LottoryUtils.cpp: implementation of the LottoryUtils class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "WinLottory.h"
#include "LottoryUtils.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
LottoryUtils::LottoryUtils()
{
}
LottoryUtils::~LottoryUtils()
{
}
void LottoryUtils::getRand(int* result,int maxnum,int num)
{
int aResult;
srand((unsigned)time(NULL));
for(int i=0;i<num;i++)
{
//result=1+(int)(10.0*rand()/(maxnum+1.0));
while(true)
{
bool flag = true;
aResult = rand()%maxnum;
for(int j=0;j<i;j++)
{
if (aResult==result[j])
{
flag = false;
printf("same one!\n");
}
}
if (flag == true)
{
result[i]=aResult;
break;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -