欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
C++語言 福利彩票的中獎號碼
[打印本頁]
作者:
51hei社區
時間:
2016-1-10 23:27
標題:
C++語言 福利彩票的中獎號碼
本帖最后由 51hei社區 于 2016-1-10 23:29 編輯
由于格式的問題本程序需要手動去掉每行尾部的-
#include<iostream>-
#include<iomanip>-
#include<time.h>-
using namespace std;-
int fun(int h,int a[],int i);-
void main()-
{int i=1,h,a[6],k=0;-
srand(time(0));-
a[0]=rand()%33;-
while(a[0]==0) //除去a[0]中的0-
{ -
a[0]=rand()%33;-
}-
-
cout<<"今晚的福利彩票的中獎號碼是:"<<endl;-
-
while(i<6)-
{ h=rand()%33;-
a[i]=h;-
if(fun(h,a,i)) i++; //除去隨機數中的相同數-
}-
cout<<setfill(' ')<<setw(2)<<' '<<setfill('*')-
<<setw(22)<<'*'<<endl; //美化 -
cout<<setfill(' ')<<setw(4)<<' ';-
for(i=0;i<6;i++)-
cout<<setw(3)<<a[i]; //輸出a[6]中的所有數-
cout<<endl;-
cout<<setfill(' ')<<setw(2)<<' '<<setfill('*') //美化 -
<<setw(22)<<'*'<<endl<<setfill(' ')<<setw(5)<<' ';-
cout<<"今晚的特別號碼是:"<<endl;-
int t=rand()%16; //隨機從16個數當中產生一個數賦給t-
while(t==0)-
{-
t=rand()%16; //除去特別號碼中的0-
}-
cout<<setfill(' ')<<setw(3)<<' '<<setfill('*')-
<<setw(20)<<'*'<<endl<<setfill(' ')<<setw(4)<<' ';-
cout<<setw(9)<<t<<endl;//輸出最后一個特別號碼-
cout<<setfill(' ')<<setw(3)<<' '<<setfill('*')<<setw(20) //美化-
<<'*'<<endl<<setfill(' ')<<setw(4)<<' '; -
}-
int fun(int h,int a[1],int i)-
{int k=0;-
while(k<i)-
{-
if(h!=0&&h!=a[k]) k++;-
else return 0;-
}-
return 1;-
}-
復制代碼
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1