Advertisement
Guest User

pizzás

a guest
May 25th, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(int argc, char *argv[]){
  6.  
  7.     int i=0,max=0,vesszo=0;
  8.     char nev[50],k;
  9.  
  10.     FILE *f;
  11.  
  12.     f=fopen(argv[1],"r");
  13.  
  14.     while(k != EOF){
  15.         k = fgetc(f);
  16.         if(k == ';'){
  17.             vesszo++;
  18.         }
  19.         if(k == '\n' || k == EOF){
  20.             if(vesszo > max){
  21.                 max = vesszo;
  22.             }
  23.             vesszo = 0;
  24.         }
  25.     }
  26.  
  27.     rewind(f);
  28.     vesszo = 0;
  29.     k='a';
  30.     printf("%d\n", max-2);
  31.  
  32.     while(k != EOF){
  33.         k = fgetc(f);
  34.  
  35.         if(k == ';'){
  36.             vesszo++;
  37.         }
  38.  
  39.         if(vesszo == 0){
  40.             nev[i] = k;
  41.             ++i;
  42.             nev[i] = '\0';
  43.         }
  44.  
  45.         if(k == '\n' || k == EOF){
  46.             if(vesszo == max){
  47.                 printf("%s\n",nev);
  48.             }
  49.             vesszo = 0;
  50.             i=0;
  51.         }
  52.     }
  53.  
  54.  
  55.     fclose(f);
  56. return EXIT_SUCCESS;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement