Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- float aux;
- void starton(void)
- {
- aux = clock();
- }
- float startoff(void)
- {
- return(clock() - aux) / CLK_TCK;
- }
- void functie_test()
- {
- int i,j,k;
- for(i=1;i<=200000;i++)
- for(j=1;j<=20000;j++)
- if(i%2)
- k=i;
- }
- void bublesort(int a[], int N) //sortare crescatoare
- {
- int i, j, temp;
- for (i = 0; i<N; i++)
- for (j = N - 1; j>i; j--)
- {
- if (a[j - 1]>a[j])
- {
- temp = a[j - 1];
- a[j - 1] = a[j];
- a[j] = temp;
- }
- }
- }
- void array(int a[], int N)
- {
- for (int i = 0; i < N; i++)
- a[i] = N - i;
- }
- void main(void)
- {
- float timp;
- //generate_a();
- //functie_test();
- int N = 12000, a[12000];
- array(a, N);
- starton();
- bublesort(a, N);
- timp = startoff();
- printf("The execution time is: %f",timp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement