Advertisement
zsoltizbekk

elso

May 26th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. /*1.
  2. országnév:zászló_színe_1:zászló_színe_2:...:zászló_méret_1:zászló_méret_2
  3. ...
  4.  
  5. Beolvasol sorokat, kiíratod, hogy melyikben van a legtöbb szín és mennyi
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11.  
  12. int main()
  13. {
  14.     char *sor, *tok;
  15.     char orszag[50], max_orszag[50];
  16.     int db, max=-1;
  17.     sor=malloc(10000000);
  18.  
  19.     while (gets(sor)){
  20.         db=0;
  21.         tok=strtok(sor, ":");
  22.         strcpy(orszag, tok);
  23.         while (tok=strtok(NULL, ":")){
  24.             db++;
  25.         }
  26.         if (max==-1 || max<db){
  27.             max=db;
  28.             strcpy(max_orszag, orszag);
  29.         }
  30.     }
  31.  
  32.     puts(max_orszag);
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement