Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. typedef struct zeneszam{
  6. int sorszam;
  7. char eloado[50];
  8. char cim[150];
  9. int hossz; //a hossz masodpercben
  10. }zeneszam;
  11.  
  12. int main(){
  13. char sor[300];
  14. zeneszam tomb[500];
  15. int i, db=0;
  16. int maxhossz=0;
  17. while (gets(sor)!=NULL){
  18. char *token=strtok(sor, ";");
  19. tomb[db].sorszam=atoi(token);
  20. token=strtok(NULL, ";");
  21. strcpy(tomb[db].eloado, token);
  22. token=strtok(NULL, ";");
  23. strcpy(tomb[db].cim, token);
  24. int hossz=(atoi(strtok(NULL, ":")))*60+atoi(strtok(NULL, ":"));
  25. tomb[db].hossz=hossz;
  26. if (hossz>=maxhossz){
  27. maxhossz=hossz;
  28. }
  29. db++;
  30. }
  31. for (i=0; i<db; i++){
  32. if (tomb[i].hossz==maxhossz){
  33. printf("%s\n", tomb[i].eloado);
  34. break;
  35. }
  36. }
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement