作者aquila018 (旅行者)
看板ESOE-94
標題[計程] 樂透開獎
時間Tue Apr 18 00:17:01 2006
我發現我每次寫出來的程式敘述和邏輯都不大一樣啦~"~
所以之前有看過我寫的用其他敘述或邏輯的人請再想想@@"
我是真的想不起我之前怎麼寫XD"
#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;
int main(void){
int lot[6]={0}; //用來放六個號碼的陣列
int num[46]={0}; //用來記錄號碼是否取過的陣列,初始為0
int i;
srand(time(NULL));
for(i=0;i<6;){
lot[i]=(rand()%46)+1;
if(num[lot[i]-1]!=0)
continue;
else{
cout<<lot[i]<<" ";
num[lot[i]-1]++;
i++;
}
}
return 0;
}
想想看吧@@"
--
╭──╮ ╭──╮ ╭╮╭╮ ☆
╭╮╭──╮ ˙
│ │ │ │ ││││ ╭╮ │││ │ ˙
│ ☆ │ │ ☆
│ ││││ ││ │││ ☆ │ .·﹒
│╭╮│ ╰─╮│ │╰╯│ ││ │││╭╮│
╰╯╰╯ ╰╯ ╰──╰ ╰╯ ╰╯╰╯╰╯ ˙ ˙ ξAquila
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.203.51.12