作者sb0917 (QQ)
看板NTUBIME101HW
标题[C++] 乐透-阵列
时间Tue Nov 18 11:38:30 2008
#include <iostream>
#include <iomanip>
#include <ctime>
using namespace std;
int loto_number();
int main()
{
srand(time(NULL));
int loto[7];
for(int i=0;i<7;i++)
{
loto[i] = loto_number();
for(int j=0;j<i;j++)
{
if(loto[i]==loto[j])
{
loto[i] = loto_number();
j = 0;
}
}
if(i==6)
cout << "特别号:";
cout << setw(2) << loto[i] << " ";
}
system("pause");
return 0;
}
int loto_number()
{
int number = rand()%42+1;
return number;
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.7.59
1F:→ ck940560:做个\b的动画会比较好@@ 单纯花俏路线 11/18 14:39
2F:→ sb0917:这是给大家看的标准版程式码啦~______~ 11/18 20:43
※ 编辑: sb0917 来自: 140.112.7.59 (11/19 17:27)