Advertisement
MARINA_GREBENAROVA

Combinations

Oct 22nd, 2021
1,099
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Combinations
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int num = int.Parse(Console.ReadLine());
  10.             int validCombinationsCount = 0;
  11.  
  12.             for (int x1 = 0; x1 <= num; x1++)
  13.             {
  14.                 for (int x2 = 0; x2 <= num; x2++)
  15.                 {
  16.                     for (int x3 = 0; x3 <= num; x3++)
  17.                     {
  18.                         if (x1 + x2 + x3 == num)
  19.                         {
  20.                             validCombinationsCount++;
  21.  
  22.                         }
  23.                     }
  24.                    
  25.                 }
  26.             }
  27.             Console.WriteLine(validCombinationsCount);
  28.         }
  29.     }
  30. }
  31.  
  32.  
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement