Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <limits.h>
- #include <string.h>
- typedef struct
- {
- char nume[20];
- float temp;
- } temperatura;
- int main()
- {
- int n,i=0;
- float temp;
- temperatura *t=(temperatura*)malloc(sizeof(temperatura));
- float max=INT_MIN;
- FILE *f=fopen("matrice_inf.txt","r");
- FILE *g=fopen("matrice_sup.txt","w");
- printf(f==NULL ? "N\n":"G\n");
- printf(g==NULL ? "N\n":"G\n");
- while(feof(f)==0)
- {
- t=(temperatura*)realloc(t,(i+1)*sizeof(temperatura));
- fscanf(f,"%s %f",&t[i].nume,&t[i].temp);
- if(t[i].temp>max)
- max=t[i].temp;
- i++;
- }
- fprintf(g, "%f ", max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement