【ANSI-C】 C言語なら俺に聞け! Part 129
■ このスレッドは過去ログ倉庫に格納されています
0675(^-^) ◆MONSOON/qo
2006/09/24(日) 05:08:16#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#define N 800000
#define M 100000
main(){
int i,j;
clock_t s,t,u;
char a[M],b[M];
for(i=0;i<M;i++)a[i]=(int)rand()*127;
s=clock();for(i=0;i<N;i++)for(j=0;a[j]!='\0';j++) b[j]=a[j];
s=clock()-s;
t=clock();for(i=0;i<N;i++)for(j=0;*(a+j)!='\0';j++)*(b+j)=*(a+j);
t=clock()-t;
u=clock();for(i=0;i<N;i++)strcpy(b,a);
u=clock()-u;
printf("%d %d %d\n",s,t,u);
}
■ このスレッドは過去ログ倉庫に格納されています