stefan1919

LastDigit

Sep 25th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 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 ConsoleApplication7
  8. {
  9.     class Program
  10.     {
  11.  
  12.         static void Main(string[] args)
  13.         {
  14.             int n = int.Parse(Console.ReadLine());
  15.             Console.WriteLine(ReturnDigit(n));
  16.         }
  17.        private static string ReturnDigit(int number)
  18.     {
  19.         string[] digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
  20.         int lastDigit = number % 10;
  21.         for (int i = 0; i < digits.Length; i++)
  22.         {
  23.             if (lastDigit == i)
  24.             {
  25.                 return digits[i];
  26.             }
  27.         }
  28.         return null;
  29.     }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment