Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <time.h>
- #define n 10000
- void timilas()
- {
- int X[n], A[n],i,s,j;
- for (i=0;i<n;i++) {
- s = X[0];
- for (j=1; j<=i; j++)
- s = s + X[j];
- A[i] = s;
- }
- }
- void Eh(){
- int X[n], A[n], i, s;
- s = 0;
- for (i=0; i<n; i++) {
- s = s + X[i];
- A[i] = s;
- }
- }
- main()
- {
- int k;
- clock_t start=clock();
- timilas();
- clock_t stop=clock();
- double duration=(double) (stop-start)*1000.0/CLOCKS_PER_SEC;
- printf("Durations(ms):%4.0f\n",duration);
- start=clock();
- for(k=0;k<1000;k++)
- {
- Eh();
- }
- system("pause");
- stop=clock();
- duration=(double) (stop-start)*1000.0/CLOCKS_PER_SEC;
- printf("Durations(ms):%4.4f\n",duration/1000);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement