Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.91 KB | None | 0 0
  1. int y1, y2, y3, y4, y5;
  2.  
  3. int segfault(int x1, int x2, int x3) {
  4.   int foo;
  5.   if (x1 < 0 || x2 < 0 || x3 < 0) {
  6.     return x1 + x2 + x3;
  7.   }
  8.   try {
  9.     if ((x1 + x2 + x3) % 3 == 0) {
  10.       y1++;
  11.       foo = segfault(x1 - ((7*x1 + 3*x2 + 5*x3)%2) - 1, x2 + 2, x3);
  12.       if ((9 * foo) % 5 >= 2) {
  13.         throw Zob1(0);
  14.       }
  15.     }
  16.     if ((x1 + x2 + x3) % 3 == 1) {
  17.       y2++;
  18.       foo = segfault(x1, x2 - ((7*x1 + 3*x2 + 5*x3)%2) - 1, x3 + 1);
  19.       if ((5 * foo) % 7 >= 3) {
  20.         throw Zob2(1);
  21.       }
  22.     }
  23.     if ((x1 + x2 + x3) % 3 == 2) {
  24.       y3++;
  25.       foo = segfault(x1, x2, x3 - ((7*x1 + 3*x2 + 5*x3)%2) - 1);
  26.       if ((4 * foo) % 3 == 2) {
  27.         throw Zob3(2);
  28.       }
  29.     }
  30.   }
  31.   catch (Zob1 x) {
  32.     if ((2*x1 + x2 + x3) % 3 == 0) {
  33.       y4++;
  34.       foo = segfault(x1 - 1, x2 + ((7*x1 + 3*x2 + 5*x3)%2) - 1, x3);
  35.       if ((9 * foo) % 5 >= 2) {
  36.         return ++y5;
  37.       }
  38.       else {
  39.         return x1+x2;
  40.       }
  41.     }
  42.   }
  43.   catch (Zob2 x) {
  44.     if ((2*x1 + x2 + x3) % 3 == 0) {
  45.       y2++;
  46.       foo = segfault(x1 - ((7*x1 + 3*x2 + 5*x3)%2) - 1, x2 + 2, x3 - 1);
  47.       if ((13 * foo) % 7 >= 3) {
  48.         return ++y4;
  49.       }
  50.       else {
  51.         return 7*x1-x2+2*x3;
  52.       }
  53.     }
  54.   }
  55.   catch (Zob3 x) {
  56.     if ((2*x1 + x2 + x3) % 3 == 0) {
  57.       y2++;
  58.       foo = segfault(x1 - 2, x2 + ((7*x1 + 3*x2 + 5*x3)%2) - 1, x3 - 1);
  59.       if ((13 * foo) % 7 >= 3) {
  60.         return ++y4;
  61.       }
  62.       else {
  63.         return 7*x1-x2+2*x3;
  64.       }
  65.     }
  66.   }
  67.   return 3*x1 + 7*x2 + x3;
  68. }
  69.  
  70. int main(int argc, char **argv) {
  71.   int a,b,c;
  72.   a = atoi(argv[1]);
  73.   b = atoi(argv[2]);
  74.   c = atoi(argv[3]);
  75.   y1 = 0;
  76.   y2 = 0;
  77.   y3 = 0;
  78.   y4 = 0;
  79.   y5 = 0;
  80.  
  81.   try {
  82.     segfault(a,b,c);
  83.   }
  84.   catch (Zob1 x) {}
  85.   catch (Zob2 x) {}
  86.   catch (Zob3 x) {}
  87.   finally {
  88.     printf("y1 : %d\ny2 : %d\ny3 : %d\ny4 : %d\ny5 : %d\n", y1, y2, y3, y4, y5);
  89.   }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement