趕快加入我們來參與討論吧!
您需要 登錄 才可以下載或查看,沒有帳號?加入我們
x
本帖最後由 Panda_Liu 於 2014-8-13 20:50 編輯
這個選號機每次都在跑到10組前就停止了
求各位學長幫我debug或優化
[C++] 純文本查看 復制代碼 #include<iostream>
#include<ctime>
#include<windows.h>
using namespace std;
int main()
{
int result,lol[5],rein=0,times,m=1;
cout<<"LOL抽獎---幸運電腦選號機"<<endl<<"請輸入你要的組數"<<endl;
cin>>times;
system("cls");
cout<<endl<<"選號結果如下"<<"共"<<times<<"組"<<"---祝您得到全角色及造型"<<endl<<endl;
srand(time(NULL));
while(times--)
{
for(int i=0;i<5;i++)
{
result=rand()%39+1;
for(int n=0;n<i;n++)
{
if(lol[n]==result)
{
rein=1;
break;
}
}
if(rein==1)
i--;
lol=result;
Sleep(10);
}
cout<<"第"<<m<<"組. ";
for(int j=0;j<5;j++)
{
cout<<lol[j]<<" ";
Sleep(200);
}
cout<<endl<<endl;
m++;
}
system("pause");
return 0;
}
By Sylveon 請愛用代碼插入的功能
|