Guest User

Number Generator

a guest
Jun 20th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace numbersGenerator
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int firstDigit = int.Parse(Console.ReadLine());
  14.             int secondDigit = int.Parse(Console.ReadLine());
  15.             int thirdDi git = int.Parse(Console.ReadLine());
  16.             int specialNumber = int.Parse(Console.ReadLine());
  17.             int controlNumber = int.Parse(Console.ReadLine());
  18.  
  19.             int number = firstDigit * 100 + secondDigit * 10 + thirdDigit;
  20.             for (int i = number; i >= 111; i--)
  21.             {
  22.                 if (i % 3 == 0)
  23.                 {
  24.                     specialNumber += 5;
  25.                     continue;
  26.                 }
  27.                 if (i % 10 == 5)
  28.                 {
  29.                     specialNumber -= 2;
  30.                     continue;
  31.  
  32.                 }
  33.                 if (i % 2 == 0)
  34.                 {
  35.                     specialNumber *= 2;
  36.                     continue;
  37.  
  38.                 }
  39.                 if (specialNumber >= controlNumber)
  40.                 {
  41.                     Console.WriteLine("Yes! Control number was reached! Current special number is {0}.", specialNumber);
  42.                     break;
  43.                 }
  44.             }
  45.             if (specialNumber < controlNumber)
  46.             {
  47.                 Console.WriteLine("No! {0} is the last reached special number.", specialNumber);
  48.             }
  49.            
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment