This repository has been archived on 2026-07-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
cmc/3sem/cnts/contest3/04.c
T
2025-04-13 21:48:15 +03:00

20 lines
302 B
C
Executable File

enum
{
MY_INT_MAX = ~0u >> (!0),
MY_INT_MIN = ~(~0u >> (!0))
};
int
satsum(int v1, int v2)
{
if (v1 > 0 && (signed int) MY_INT_MAX - v1 < v2) {
return MY_INT_MAX;
}
if (v1 < 0 && (signed int) MY_INT_MIN - v1 > v2) {
return MY_INT_MIN;
}
return v1 + v2;
}