Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- int count = 0; //брой на комбинациите, които са валидни
- //1. комбинация от 3 числа
- for (int first = 0; first <= n; first++)
- {
- for (int second = 0; second <= n; second++)
- {
- for (int third = 0; third <= n; third++)
- {
- //комбинация от числата: first, second, third
- if (first + second + third == n)
- {
- //валидна комбинация
- // cout << first << " + " << second << " + " << third << " = " << n << endl;
- count++;
- }
- }
- }
- }
- cout << count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement