Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace FlipTheNumber
- {
- class Program
- {
- static int hundreds;
- static int dozens;
- static int ones;
- static int FirstDigit;
- static int SecondDigit;
- static int ThirdDigit;
- static void Main(string[] args)
- {
- int num;
- Console.WriteLine("Enter a three-digit number:");
- num = Convert.ToInt32(Console.ReadLine());
- hundreds = num;
- for (int i = 1; i < 10; i++)
- {
- hundreds = hundreds - 100;
- if (hundreds < 100)
- {
- dozens = hundreds;
- FirstDigit = i;
- i = 10;
- }
- }
- for (int i = 1; i < 10; i++)
- {
- dozens = dozens - 10;
- if (dozens < 10)
- {
- ones = dozens;
- SecondDigit = i;
- i = 10;
- }
- }
- for (int i = 1; i < 10; i++)
- {
- ones = ones - 1;
- if (ones == 0)
- {
- ThirdDigit = i;
- i = 10;
- }
- }
- int result = ThirdDigit * 100 + SecondDigit * 10 + FirstDigit;
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement