argentinapb

Untitled

Aug 19th, 2019
120
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 10
  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 = 10;
  28. int vet[MAX];
  29. char p;
  30.  
  31.  
  32. FILE *f;
  33. // f = fopen("maior1.txt","a");
  34.  
  35.  
  36.  
  37.  
  38. //for(int i = 0; i < MAX; i++){
  39. // fprintf(f,"%d ",criar (n));
  40.  
  41. // }
  42. i = 0;
  43. f = fopen("maior1.txt","r");
  44.  
  45. while (!feof(f))
  46. {
  47. fscanf(f,"%d",&vet[i]);
  48. i++;
  49. }
  50.  
  51. int x;
  52. x = maior(&vet);
  53. printf("\no maior eh: %d ", x);
  54.  
  55. fclose(f);
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment