int* create_array(char category, int n){
int *a;
a = malloc(n* sizeof(int));
for (int i = 0; i < n; i++) {
int x;
srand(time(NULL));
x = rand();
a[i] = x;
}
我正在学习C++,我似乎无法找到我的问题的答案。当我运行我的代码时,我没有遇到任何编译器错误,但当我调用函数“getVin()”(应该使用“generate()”函数生成一个随机数)时,它不会执行所以。它输出一个零。这里是我的类(来自头文件): class Vehicle {
public:
Vehicle();
static int generate();
con
// An efficient program to randomly select a number from stream of numbers.
#include <iostream>
using namespace std;
#include <stdlib.h>
#include <time.h>
/* A program to randomly select a item