Advertisement
argentinapb

Untitled

Aug 25th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define MAX 1000
  5.  
  6. int maior(int *vet){
  7. int aux;
  8. int i;
  9. aux = vet[0];
  10. for(i = 0; i < MAX; i++){
  11. if(aux < vet[i]){
  12. aux = vet[i];
  13. }
  14. }
  15. return aux;
  16. }
  17.  
  18. int criar(int n){
  19. int x;
  20. x = rand () % n;
  21. return x;
  22. }
  23.  
  24.  
  25. int main(){
  26. int i = 0;
  27. int n = 1000;
  28. int vet[MAX];
  29. char p;
  30.  
  31.  
  32. FILE *f;
  33. // f = fopen("maior3.txt","a");
  34.  
  35.  
  36.  
  37. // for(int i = 0; i < MAX; i++){
  38. // fprintf(f,"%d ",criar (n));
  39.  
  40. // }
  41. i = 0;
  42. f = fopen("maior3.txt","r");
  43.  
  44. while (!feof(f))
  45. {
  46. fscanf(f,"%d",&vet[i]);
  47. i++;
  48. }
  49.  
  50. int x;
  51. x = maior(&vet);
  52. printf("\no maior eh: %d ", x);
  53.  
  54. fclose(f);
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement