Exemplo n.º 1
0
/**
 * The thread will begin control in this function.
 * Each thread will output its own version of "Hello World"
 */
void *runner(void *param) 
{
	int tam=1000;
	int vet[tam];
	double ti,tf,insert,qu,sh,he,se;
	struct timeval tempo_inicio, tempo_fim;
	aleatorio(vet,tam);
	//imprimir(vet,tam);
	gettimeofday(&tempo_inicio,NULL);
	Selecao(vet,tam);
	gettimeofday(&tempo_fim,NULL);
	//imprimir(vet,tam);
	tf =(double)tempo_fim.tv_usec+((double)tempo_fim.tv_sec*1000000);
	ti =(double)tempo_inicio.tv_usec+((double)tempo_inicio.tv_sec*1000000);
	se = (tf-ti);
	printf("|  Selecao  | %.0lf microsegundos \n",se);
	pthread_exit(0);
}
Exemplo n.º 2
0
int main(int argc, char *argv[]){ 

  n = MaxTam;   /*Tamanho do arranjo a ser ordenado*/
 
  arq = fopen("vetor.txt","r");
  printf("Vetor a ser pesquisado:\n\n");
  for (i = 1; i <= n; i++) {
    fscanf(arq, "%d", &A[i].Chave);
    printf("%10d\n", A[i].Chave);
  }
	 
  printf("Desordenado : ");
  Imprime(A, &n);
  printf("Selecao   \n");
  Selecao(A, &n);
  printf("Ordenado : ");
  Imprime(A, &n);
  
  system("PAUSE");
  return 0;
}