#include <iostream>
#include <ctime>
using namespace std;
int main(int argc, char *argv[])
{
srand((unsigned int)(time(NULL)));
int i,j,k,l,m,n;
i=j=k=l=m=n=-1;
unsigned int b;
for(int a=0;a<6;a++)
{
do
{
b=rand()%50;
switch(a)
{
case 0:
i=b;
break;
case 1:
j=b;
break;
case 2:
k=b;
break;
case 3:
l=b;
break;
case 4:
m=b;
break;
case 5:
n=b;
break;
}
}while((bool)(b^i)+(bool)(b^j)+(bool)(b^k)+(bool)(b^l)+(bool)(b^m)+(bool)(b^n)!=5);
cout<<b<<endl;
}
return 0;
}
第5章循环练习:0到49中随机选择6个不同的数。
最新推荐文章于 2020-09-06 23:58:30 发布