Advertisement
abasar

ex1 actions

Nov 29th, 2015
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 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 Exercises
  8. {
  9.     class Program
  10.     {
  11.         static double Right(int num)
  12.         {
  13.             int digits = 1, rep = num;
  14.             double last;
  15.             while (rep / 10 != 0)
  16.             {
  17.                 digits++;
  18.                 rep /= 10;
  19.             }
  20.             last = num % 10 * Math.Pow(10, digits - 1);
  21.             num /= 10;
  22.             return num + last;
  23.         }
  24.  
  25.         static void Main(string[] args)
  26.         {
  27.             int i, num;
  28.             Random rnd = new Random();
  29.             for (i = 0; i < 10; i++)
  30.             {
  31.                 num = rnd.Next(46, 139);
  32.                 Console.WriteLine("Before: {0}, after: {1}", num, Right(num));
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement