anizko

04. Combination

Apr 17th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Combination
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int counter = 0;
  11.    
  12.  
  13.             for (int a = 0; a <= n; a++)
  14.             {
  15.                 for (int b = 0; b <= n; b++)
  16.                 {
  17.                     for (int c = 0; c <= n; c++)
  18.                     {
  19.                         for (int d = 0; d <= n; d++)
  20.                         {
  21.                             for (int e = 0; e<= n; e++)
  22.                             {
  23.  
  24.                                 if (a  + b  + c  + d  + e == n)
  25.                                 {
  26.                                     counter++;
  27.                                 }
  28.                             }
  29.                         }
  30.                     }
  31.                 }
  32.             }
  33.  
  34.            
  35.             Console.WriteLine(counter);
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment