Jater

Ilya_function

Dec 4th, 2020
561
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <conio.h>
  2. #include <stdio.h>
  3. #include <limits.h>
  4.  
  5. int fun_sum(int a, int b) {//фун-я сложения
  6.     int c = 0;
  7.     if (a > 0 && b > 0 && (INT_MAX - b > a) || a < 0 && b < 0 && (INT_MIN - b < a)) {
  8.         c = a + b;
  9.         printf("%d\n",c);
  10.         return (int)c;
  11.     }
  12.     else {
  13.         printf("!1\n");
  14.     }
  15. }
  16.  
  17. int fun_sub(int a, int b) {//фун-я вычитания
  18.     int c = 0;
  19.     if (a > 0 && b < 0 && (INT_MAX + b > a) || a < 0 && b > 0 && (INT_MIN + b < a) || (a < 0 && b < 0) || (a > 0 && b > 0)) {
  20.         c = a - b;
  21.         printf("%d\n",c);
  22.         return (int)c;
  23.     }
  24.     else {
  25.         printf("!2\n");
  26.     }
  27. }
  28.  
  29. int fun_mul(int a, int b) {//фун-я умножения
  30.     int c = 0;
  31.     if (abs(INT_MAX / b) > abs(a)) {
  32.         c = a * b;
  33.         printf("%d\n",c);
  34.         return (int)c;
  35.     }
  36.     else {
  37.         printf("!3\n");
  38.     }
  39. }
  40.  
  41. void main()
  42. {
  43.     int a, b;
  44.     double r = 0;
  45.     printf("Введите число a:\n");
  46.     scanf("%d%d", &a, &b);
  47.     r = fun_sub(a, b);
  48.     r = fun_mul(a, r);
  49.     r = fun_sum(r, b);
  50. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×