Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <limits.h>
  4. #include <string.h>
  5. typedef struct
  6. {
  7. char nume[20];
  8. float temp;
  9. } temperatura;
  10.  
  11. int main()
  12. {
  13. int n,i=0;
  14. float temp;
  15. temperatura *t=(temperatura*)malloc(sizeof(temperatura));
  16. float max=INT_MIN;
  17. FILE *f=fopen("matrice_inf.txt","r");
  18. FILE *g=fopen("matrice_sup.txt","w");
  19. printf(f==NULL ? "N\n":"G\n");
  20. printf(g==NULL ? "N\n":"G\n");
  21. while(feof(f)==0)
  22. {
  23. t=(temperatura*)realloc(t,(i+1)*sizeof(temperatura));
  24. fscanf(f,"%s %f",&t[i].nume,&t[i].temp);
  25. if(t[i].temp>max)
  26. max=t[i].temp;
  27. i++;
  28.  
  29. }
  30. fprintf(g, "%f ", max);
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement