Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define max(a, b) (a) > (b) ? (a) : (b)
- #define min(a, b) (a) < (b) ? (a) : (b)
- int main()
- {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- char whr[10];
- int n, x, y;
- bool home;
- int x2, z1, z2;
- scanf("%d\n", &n);
- for(int i=0; i<n; i++)
- {
- scanf("The Machinegunners played %[^ ] game, scored %d goals, and conceded %d goals.\n", whr, &x, &y);
- if(strcmp(whr, "home") == 0) home = true;
- else home = false;
- for(int i = 0; i <= 30; i++)
- {
- if( ( (x+i)>(y)) || ( (x+i) == (y) && home && (i>=y)) || ( (x+i) == (y) && !home ))
- {
- x2=i;
- break;
- }
- }
- for(int i = 30; i >= 0; i--) // dlya maximuma
- {
- if( ( (x+i)<(y+30)) || ( (x+i) == (y+30) && !home) || ( (x+i) == (y+30) && home) && (y>=i) )
- {
- z2=i;
- break;
- }
- }
- printf("%d %d\n", x2, z2);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement