这个菜鸟的疑惑
看过关于随机数生成大虾们发的文章;也菜了个3个数的:#include<iostream>
#include<time.h>
#include<stdlib.h>
using namespace std;
int main()
{
int i,num1,num2,num3;
srand(time(NULL));
num1=rand()%10;
num2=rand()%10;
num3=rand()%10;
cin>>i;
for(;i=1;)
{
while(num1==num2||num1==num3||num2==num3)
{
num1=rand()%10;num2=rand()%10;num3=rand()%10;
}
cout<<num1<<" "<<num2<<" "<<num3<<" ";
cin>>i;
num1=0;num2=0;
}
system("pause");
return 0;
}
char question()
{问题:
1。如何让随机数大小限定在0-n;
2。如何生成n个(n比较大)个各不相同的随机数;
谢谢;
}