Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define max(a, b) (a) > (b) ? (a) : (b)
  5. #define min(a, b) (a) < (b) ? (a) : (b)
  6.  
  7.  
  8. int main()
  9. {
  10.         freopen("input.txt", "r", stdin);
  11.         freopen("output.txt", "w", stdout);
  12.  
  13.         char whr[10];
  14.         int n, x, y;
  15.         bool home;
  16.         int x2, z1, z2;
  17.         scanf("%d\n", &n);
  18.         for(int i=0; i<n; i++)
  19.         {
  20.                 scanf("The Machinegunners played %[^ ] game, scored %d goals, and conceded %d goals.\n", whr, &x, &y);
  21.                 if(strcmp(whr, "home") == 0) home = true;
  22.                 else home = false;
  23.  
  24.                 for(int i = 0; i <= 30; i++)
  25.                 {
  26.                         if( ( (x+i)>(y)) || ( (x+i) == (y) && home && (i>=y)) || ( (x+i) == (y) && !home ))
  27.                         {
  28.                                 x2=i;
  29.                                 break;
  30.                         }
  31.                 }
  32.                 for(int i = 30; i >= 0; i--) // dlya maximuma
  33.                 {
  34.                         if( ( (x+i)<(y+30)) || ( (x+i) == (y+30) && !home) || ( (x+i) == (y+30) && home) && (y>=i) )
  35.                         {
  36.                                 z2=i;
  37.                                 break;
  38.                         }
  39.                 }
  40.  
  41.                 printf("%d %d\n", x2, z2);
  42.         }
  43.  
  44.  
  45.         return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement