第1个回答 2014-07-17
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int a,b,c;//保存3个随机数
srand((unsigned)time(NULL));
a=rand()%10;//产生一个0~9的随机数
while(1)//产生一个不等于a的0~9的随机数
{
b=rand()%10;
if(b!=a) break;
}
while(1)//产生一个不等于a和b的0~9的随机数
{
c=rand()%10;
if((c!=a) && (c!=b)) break;
}
printf("a=%d,b=%d,c=%d\n",a,b,c);
return 0;
}