C++随机数生成QQ号
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
void main() {
int num = 0;//QQ位数
int number = 0;//QQ个数
cout << "请输入QQ号的位数" << endl;
cin >> num;//输入QQ位数
cout << "请输入生成的个数" << endl;
cin >> number;//输入QQ个数
srand(time(0));//设置种子
cout << "-------------" << endl;
while (number--)//循环条件
{
int* shu = new int[num];//动态创建数组
for (int i = 0; i < num; i++)
{
*(shu + i) = rand() % 9;//间值访问数组赋值
cout << *(shu + i);//输出
}
cout << endl;
delete shu;//释放
}
cout << "-------------" << endl;
}
效果图: