Advertisement
sellmmaahh

tabela u datoteci ispit

Feb 6th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.02 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. void f (float* niz1, float* niz2, float* niz3, float* niz4 int vel)
  5. {
  6.     int i=0;
  7.     if (niz1[i]>niz2[i] && niz1[i]>niz3[i])
  8.         niz4[i]=niz1[i];
  9.     if (niz2[i]>niz1[i] && niz2[i]>niz3[i])
  10.         niz4[i]=niz2[i];
  11.     if (niz3[i]>niz1[i] && niz3[i]>niz2[i])
  12.         niz4[i]=niz3[i];
  13.    
  14. }
  15.  
  16. int main ()
  17. { int i=0, vel;
  18. float niz1[100], niz2[100], niz3[100];
  19.     FILE* Ulaz=fopen("Brojevi.txt", "r");
  20.     if (Ulaz==NULL) {
  21.         printf ("Greska pri otvaranju datoteke!");
  22.     exit (1); }
  23.     FILE* Izlaz==fopen ("Statistika.txt", "w");
  24.     if (Izlaz==NULL)
  25.     {
  26.         printf("Greska pri otvaranju datoteke! ");
  27.         fclose(Ulaz);
  28.         exit(1);
  29.     }
  30.     fscanf(Ulaz, "%d", &vel);
  31.     while (fscanf(Ulaz, "%f %f %f", &niz1[i], &niz2[i], &niz3[i])==3 && i<100 )
  32.         i++;
  33.     vel=i;
  34.     f1(niz1, niz2, niz3, niz4, vel);
  35.     for (i=0, i<vel; i++)
  36.     {
  37.         fprintf(Izlaz,"%f", niz4[i]);
  38.     }    
  39.     fclose(Ulaz);
  40.     fclose (Izlaz);
  41.    
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement