Advertisement
vlad0

TripleRotation-bgcoder29DEC12

Dec 30th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace _01.TripleRotation
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int number = int.Parse(Console.ReadLine());
  13.             int length = Convert.ToString(number).Length;
  14.             int digit;
  15.             int result = (int)Math.Pow(10,length - 1);
  16.            
  17.             for (int i = 0; i < 3; i++)
  18.             {
  19.                 digit = number % 10;
  20.                 number = number/10;
  21.                
  22.                 if (digit != 0)
  23.                 {
  24.                     number += digit * result;
  25.                 }
  26.                 else
  27.                 {
  28.                     length = Convert.ToString(number).Length;
  29.                     result = (int)Math.Pow(10, length - 1);
  30.                 }
  31.  
  32.             }
  33.            
  34.             Console.WriteLine(number);
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement