Advertisement
simeon3000

Number Generator

Jun 20th, 2017
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1.             int M = int.Parse(Console.ReadLine());
  2.             int N = int.Parse(Console.ReadLine());
  3.             int L = int.Parse(Console.ReadLine());
  4.             int special = int.Parse(Console.ReadLine());
  5.             int control = int.Parse(Console.ReadLine());
  6.  
  7.             for (int i = M; i >= 1; i--)
  8.             {
  9.                 for (int j = N; j >= 1; j--)
  10.                 {
  11.                     for (int k = L; k >= 1; k--)
  12.                     {
  13.                         int num = int.Parse($"{i}{j}{k}");
  14.  
  15.                         if (num % 3 == 0) special += 5;
  16.                         else if (num % 10 == 5) special -= 2;
  17.                         else if (num % 2 == 0) special *= 2;
  18.  
  19.                         if (special >= control)
  20.                         {
  21.                             Console.WriteLine($"Yes! Control number was reached! Current special number is {special}.");
  22.                             return;
  23.                         }
  24.                     }
  25.                 }
  26.             }
  27.  
  28.             Console.WriteLine($"No! {special} is the last reached special number.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement