#include <iostream> int main() { int givenSumNumber, n = 0; std::cin >> givenSumNumber; for (int a = 0x0; a <= givenSumNumber; a++) { for (int b = 0x0; b <= givenSumNumber; b++) { if (a+b == givenSumNumber) n++; } } std::cout << n << "\n"; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <iostream> int main() { int givenSumNumber, n = 0; std::cin >> givenSumNumber; for (int a = 0x0; a <= givenSumNumber; a++) { for (int b = 0x0; b <= givenSumNumber; b++) { if (a+b == givenSumNumber) n++; } } std::cout << n << "\n"; return 0; } |