Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <time.h>
- #include <stdlib.h>
- #include <string.h>
- #include <windows.h>
- #define MAX 1000
- int maior(int *vet){
- int aux;
- int i;
- aux = vet[0];
- for(i = 0; i < MAX; i++){
- if(aux < vet[i]){
- aux = vet[i];
- }
- }
- return aux;
- }
- int criar(int n){
- int x;
- x = rand () % n;
- return x;
- }
- int main(){
- int i = 0;
- int n = 1000;
- int vet[MAX];
- char p;
- FILE *f;
- // f = fopen("maior3.txt","a");
- // for(int i = 0; i < MAX; i++){
- // fprintf(f,"%d ",criar (n));
- // }
- i = 0;
- f = fopen("maior3.txt","r");
- while (!feof(f))
- {
- fscanf(f,"%d",&vet[i]);
- i++;
- }
- LARGE_INTEGER freq;
- LARGE_INTEGER t1,t2;
- double tempo;
- QueryPerformanceFrequency(&freq);
- QueryPerformanceCounter(&t1);
- int x;
- x = maior(&vet);
- printf("\no maior eh: %d ", x);
- QueryPerformanceCounter(&t2);
- tempo = (t2.QuadPart-t1.QuadPart)*1000.0/freq.QuadPart;
- printf("Tempo de execucao = %lf\n",tempo);
- fclose(f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement