Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- //x1, x2, x3 -> 0 до n
- int count = 0; //брой на валидни комбинации
- for (int x1 = 0; x1 <= n ; x1++)
- {
- for (int x2 = 0; x2 <= n ; x2++)
- {
- for (int x3 = 0; x3 <= n; x3++)
- {
- int sum = x1 + x2 + x3;
- if (sum == n) {
- count++;
- }
- }
- }
- }
- cout << count << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment