/////////////////////////////////////////// C-Free 4.1// MinGW 3.4.5// veket的小号/////////////////////////////////////////#include <cstdlib>#include <iostream>using namespace std;int main(){ int i; int n = 10; int randnum; cout << "请输入位数n:" << endl; cin >> n; cin.sync(); cin.clear(); int *p = new int[n]; srand(time(NULL)); randnum = 0; for(i=0;i<n;i++) { p[i] = rand()%10; randnum = randnum*10 + p[i]; } cout << n << "位随机数为:" << randnum << endl; delete [] p; return 0;}
温馨提示:答案为网友推荐,仅供参考