|
本帖最后由 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;-
- }-
复制代码
|
|