代码:
#include "stdafx.h"
#include "stdio.h"
#include "math.h"
#include "stdlib.h"
#include "time.h"
int main()
{
time_t start, end;
time (&start);
int i;
double dif;
/*int serie[100000];*/
/* int *serie = malloc( sizeof(int) );
for (i = 0; i <= 100000; i++) {
*serie(i)=rand();
printf("%d \n", serie[i]);
}
*/
time (&end);
dif = difftime (end, start);
printf ("Time of execution is: %f\n", dif );
getchar();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
简介:(无需阅读)
我从大约3年前就知道了一些C++.我决定学习C来创建一个"快速"子集和算法.这是一个学习C的简单程序.问题是创建随机数和时间.当我使用Visual Studio编译为默认或C++时,此代码实际上有效,但我决定在C中执行此操作,并且我想创建一个动态数组.
似乎new在C中没有.我们必须使用malloc,但编译malloc我认为它必须在C中编译.在C++中,它给了我这个错误:
cannot convert from 'void …Run Code Online (Sandbox Code Playgroud)