Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include<time.h>
- void ordena(int *a,int n){
- int i,j,min;
- int t;
- for (i = 0; i <= n; i++) {
- min = i;
- for (j = i+1; j <=n; j++)
- if (a[j] < a[min]) min = j;
- t = a[min]; a[min] = a[i]; a[i] = t;
- }
- }
- int main()
- {
- int h,k;
- FILE* saida;
- saida=fopen("/home/vhugo/Γrea de trabalho/novo.txt","w");
- if(saida==NULL){
- printf("Deu merda");
- return 0;
- }
- for(h=1;h<=10000;h++) {
- fprintf(saida,"case: %d\n",h);
- for (k = 1; k <= 1000; k++) {
- clock_t t_i, t_f;
- double tempo_total;
- int *vet;
- int i;
- vet = ( int *) malloc(sizeof(int) * h);
- for (i = 0; i < h; i++) {
- vet[i] = rand() % 100;
- }
- t_i = clock();
- ordena(vet, h);
- t_f = clock();
- tempo_total = t_f - t_i;
- fprintf(saida, "%lf\n", tempo_total);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement