BlueBear

Untitled

Nov 18th, 2012
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. void najncena()
  2. {
  3.     FILE *fr;
  4.     char p[POCET];
  5.     int i,v,s;
  6.     double min,cena,w;
  7.     min=10000;
  8.     if ((fr = fopen("zajazdy.txt", "r")) == NULL)
  9.     {
  10.         printf("Neotvoreny subor\n");
  11.         return 1;
  12.     }
  13.     while (!(feof(fr)))
  14.     {
  15.         fgets(p,32,fr);
  16.         fgets(p,32,fr);
  17.         fgets(p,32,fr);
  18.         fscanf(fr, "%d\n", &v);
  19.         fscanf(fr, "%lf\n", &cena);
  20.         fgets(p,32,fr);
  21.         fscanf(fr, "%d\n", &s);
  22.         if ((v==5)&&(min>(cena/s))&&(s!=0))
  23.         {
  24.             min=cena/s;
  25.             w=cena;
  26.         }
  27.        
  28.  
  29.     }
  30.     printf("%lf\n",w);
  31.     if (fclose(fr)== EOF)
  32.     {
  33.         printf(" Subor sa nepodarilo zatvorit\n");
  34.         return 1;
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment