11-25 1,519PVs
I want to say sorry because this article is writing by English. I’m using Ubuntu System. So I dont have a Chinese input method. Here is the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
/*This file's program can counting the running time of a program.*/ #include <stdio.h> #include <time.h> int main(int argc,char *agrv[]) { int sum = 0; int A = 6000; time_t start,end; //time_t is same as long int clock_t cstart,cend; // clock_t is same as int start = time(NULL); //Clear the start. time(NULL) will return current time of system. cstart = clock(); //clcok() is a counting funciton. printf("start:%dn",(int)start); printf("cstart:%dn",(int)cstart ); printf("The program start running...n"); //This program will counting this for-loop's running time. for (int i = 0;i<A;i++) { if(i%10==6) printf(" %d",i); sum +=i; } end = time(NULL); cend = clock(); printf("n end:%dn",(int)end); printf("cend:%dn",(int)cend); printf("n The end of running. n"); printf("The running time is : %lf millisecond(ms) n",(double)(cend - cstart)); return 0; } |
I also edit my blog whose title is “This innocence is brilliant”. There is somthing wrong with the background music. The music player is too ugly to use. So I re-edited it and it looks beautiful now. I hope you can enjoy it. 🙂