Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <stdio.h>
- #include <limits.h>
- int fun_sum(int a, int b) {//фун-я сложения
- int c = 0;
- if (a > 0 && b > 0 && (INT_MAX - b > a) || a < 0 && b < 0 && (INT_MIN - b < a)) {
- c = a + b;
- printf("%d\n",c);
- return (int)c;
- }
- else {
- printf("!1\n");
- }
- }
- int fun_sub(int a, int b) {//фун-я вычитания
- int c = 0;
- 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)) {
- c = a - b;
- printf("%d\n",c);
- return (int)c;
- }
- else {
- printf("!2\n");
- }
- }
- int fun_mul(int a, int b) {//фун-я умножения
- int c = 0;
- if (abs(INT_MAX / b) > abs(a)) {
- c = a * b;
- printf("%d\n",c);
- return (int)c;
- }
- else {
- printf("!3\n");
- }
- }
- void main()
- {
- int a, b;
- double r = 0;
- printf("Введите число a:\n");
- scanf("%d%d", &a, &b);
- r = fun_sub(a, b);
- r = fun_mul(a, r);
- r = fun_sum(r, b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement