武神赵子龙马超打张飞:关于C++生成随机数字的代码

来源:百度文库 编辑:高校问答 时间:2024/05/04 14:54:40
我想要C++生成随机数字的代码,把数字cout出来。
随机生成N位数,N由我来设定是多少位。
那个代码是什么啊,有高手可以告诉我码?
不行啊,第一个兄弟发的那个程序不符合我的要求。。。。

#include <stdlib.h>
#include <iostream.h>
#include <math.h>
int main()
{
int n;
cin>>n;
cout<<(int)(rand()*pow(10,n));
}