Advertisement
silvana1303

profit

Apr 25th, 2020
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Loops
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int oneLeva = int.Parse(Console.ReadLine());
  10.             int twoLeva = int.Parse(Console.ReadLine());
  11.             int fiveLeva = int.Parse(Console.ReadLine());
  12.             int sum = int.Parse(Console.ReadLine());
  13.  
  14.             for (int i = 0; i <= oneLeva; i++)
  15.             {
  16.                 for (int j = 0; j <= twoLeva; j++)
  17.                 {
  18.                     for (int k = 0; k <= fiveLeva; k++)
  19.                     {
  20.                         if ( (i * 1) + (j * 2) + (k * 5) == sum)
  21.                         {
  22.                             Console.WriteLine($"{i} * 1 lv. + {j} * 2 lv. + {k} * 5 lv. = {sum} lv.");
  23.                         }
  24.                     }
  25.                 }
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement