Advertisement
Spocoman

03. Combinations

Sep 11th, 2023
1,040
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7.     int num;
  8.     cin >> num;
  9.  
  10.     int counter = 0;
  11.  
  12.     for (int a = 0; a <= num; a++) {
  13.         for (int b = 0; b <= num; b++) {
  14.             for (int c = 0; c <= num; c++) {
  15.                 if (a + b + c == num) {
  16.                     counter++;
  17.                 }
  18.             }
  19.         }
  20.     }
  21.  
  22.     cout << counter<< endl;
  23.  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement