1#include <stdio.h>2#include <math.h>3#include <time.h>4 5 clock_t start,stop;6 #defineMax 1e77 #defineNum 100
8 voidPutin (Double*);9 voidFDouble*,int,Double );Ten voidffDouble*a,intNDoublex); One voidTimetext (void(*point) (Double*,int,Double),Double*,int,Double);
A voidMain () - { - DoubleA[num]; the Putin (a); -Timetext (F,a,num,1.1); -Timetext (Ff,a,num,1.1); - + } - + A voidPutin (Double*a) at{inti; - for(i=0; i<num;i++) -* (a+i) = (Double) I; - } - - voidFDouble*a,intNDoublex) in{inti; - Doublesum=0; to for(i=0; i<n;i++) +sum=sum+a[i]*Pow (x,i); - the } * $ voidffDouble*a,intNDoublex)Panax Notoginseng{inti; - Doublesum=a[n-1]; the for(i=n-2; i>=0; i--) +sum=sum*x+A[i]; A } the + voidTimetext (void(*point) (Double*,int,Double),Double*a,intNDoublex) - { $ inti; $ Doubleduration; -start=clock (); - for(i=0; i<max;i++) the(*Point ) (a,n,x); -stop=clock ();WuyiDuration= ((Double) (Stop-start))/max/Clk_tck; theprintf"%f\n", duration); -printf"%f\n",(Double) (stop-start)); Wuprintf"\ n"); -}
Data structure and algorithm 1-2 C language running time detection algorithm