Advertisement
SarduMurakumo

FlipTheNumber

Jul 5th, 2021
999
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. using System;
  2.  
  3. namespace FlipTheNumber
  4. {
  5.     class Program
  6.     {
  7.  
  8.         static int hundreds;
  9.         static int dozens;
  10.         static int ones;
  11.         static int FirstDigit;
  12.         static int SecondDigit;
  13.         static int ThirdDigit;
  14.  
  15.         static void Main(string[] args)
  16.         {
  17.  
  18.             int num;
  19.             Console.WriteLine("Enter a three-digit number:");
  20.             num = Convert.ToInt32(Console.ReadLine());
  21.              
  22.  
  23.             hundreds = num;
  24.  
  25.             for (int i = 1; i < 10; i++)
  26.             {
  27.                 hundreds = hundreds - 100;
  28.                 if (hundreds < 100)
  29.                 {
  30.                     dozens = hundreds;
  31.                     FirstDigit = i;
  32.                     i = 10;
  33.                 }
  34.             }
  35.  
  36.             for (int i = 1; i < 10; i++)
  37.             {
  38.                 dozens = dozens - 10;
  39.                 if (dozens < 10)
  40.                 {
  41.                     ones = dozens;
  42.                     SecondDigit = i;
  43.                     i = 10;
  44.                 }
  45.             }
  46.  
  47.             for (int i = 1; i < 10; i++)
  48.             {
  49.                 ones = ones - 1;
  50.                 if (ones == 0)
  51.                 {
  52.                     ThirdDigit = i;
  53.                     i = 10;
  54.                 }
  55.             }
  56.  
  57.             int result = ThirdDigit * 100 + SecondDigit * 10 + FirstDigit;
  58.  
  59.             Console.WriteLine(result);
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement