Re: [問題] 樂透程式結果錯誤
count[46];
void lotto()
{
int balls[46];
for(int i = 0; i < 46; i++)
balls[i] = i;
for(int i = 0; i < 6; i++)
{
int index = rand() % (46 - i);
cout << balls[index] + 1 << " ";
count[balls[index]]++;
balls[index] = balls[45 - i];
}
cout << endl;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.24.154.142
→
05/22 00:26, , 1F
05/22 00:26, 1F
→
05/22 00:28, , 2F
05/22 00:28, 2F
→
05/22 01:50, , 3F
05/22 01:50, 3F
→
05/22 01:53, , 4F
05/22 01:53, 4F
→
05/22 02:04, , 5F
05/22 02:04, 5F
討論串 (同標題文章)
完整討論串 (本文為第 3 之 3 篇):
問題
1
4