#include<stdio.h>
#include<string.h>
#include<time.h>
const int maxn = 1e7;
double a[maxn];
int main (){
clock_t ts1,te1,ts2,te2;
int s,ms;
ts1 = clock();
for (int i = 0; i < maxn; i++){
a[i] = 0;
}
te1 = clock();
ts2 = clock();
memset(a, 0, sizeof(a));
te2 = clock();
printf("const int maxn = 1e7;\ndouble a[maxn];\n:\nfor: %ldms\nmemset:%ldms ", te1-ts1,te2-ts2);
}
在本地运行大概memset 速度是for 的2到5倍;
memset十几到三十几ms;
for60+ms;