
C++产生随机数的
#include<iostream.h>#include<stdlib.h>voidmain(){inta=rand()%10;intb=rand()%100;intte...
#include <iostream.h>
#include <stdlib.h>
void main()
{
int a = rand()%10;
int b = rand()%100;
int temp;
temp=int(b/a);
for(int i=0;i<10;i++)
{
cout<<a<<'\\'<<b<<"="<<temp<<endl;
}
}
我看书自学的,不知道rand()这个到底怎么用?
我这样写为什么10次的结果都是一样的呢? 展开
#include <stdlib.h>
void main()
{
int a = rand()%10;
int b = rand()%100;
int temp;
temp=int(b/a);
for(int i=0;i<10;i++)
{
cout<<a<<'\\'<<b<<"="<<temp<<endl;
}
}
我看书自学的,不知道rand()这个到底怎么用?
我这样写为什么10次的结果都是一样的呢? 展开
21个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |