Advertisement
Guest User

Díjazás

a guest
May 23rd, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.08 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7.     int i,j;
  8.     char sor[301];
  9.     while (gets(sor) != NULL)
  10.     {
  11.         int count=0;
  12.         for (i=0;i<strlen(sor);++i)
  13.             if (sor[i] == '|')
  14.                 count++;
  15.         if (count == 2)
  16.             printf("0\n");
  17.         else
  18.         {
  19.             int t[count];
  20.             int k=0;
  21.             strtok(sor, "|");
  22.             for (j=0;j<count;j++)
  23.             {
  24.                 char szam[sizeof(int)];
  25.                 strcpy(szam,strtok(NULL,"|"));
  26.                 t[j]=atoi(szam);
  27.             }
  28.             int max1 = t[0], max2 = 0, max3 = 0;
  29.             for (i = 1; i < count; i++)
  30.                 if (t[i] > max1)
  31.                     max1 = t[i];
  32.             for (i = 0; i < count; i++)
  33.                 if (t[i] > max2 && t[i] < max1)
  34.                     max2 = t[i];
  35.             for (i = 0; i < count; i++)
  36.                 if (t[i] > max3 && t[i] < max2)
  37.                     max3 = t[i];
  38.             printf("%d\n",max3);
  39.         }
  40.     }
  41.     return EXIT_SUCCESS;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement