SHARE
TWEET

Untitled

a guest Feb 29th, 2016 647 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace num2string_100_SC_SoftUni_home
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var n = int.Parse(Console.ReadLine());
  14.             string[] a = new string[] { "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten" };
  15.             string[] b = new string[] { "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
  16.             string[] c = new string[] { "", "", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety" };
  17.             string[] d = new string[] { "", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
  18.             string h = "hundred";
  19.  
  20.             if (n <= 10 && n >= 0)
  21.             {
  22.                 string outun = a[n];
  23.                 Console.WriteLine(outun);
  24.             }
  25.  
  26.             else if (n > 20 && n < 100)
  27.             {
  28.                 int units = n % 10;
  29.                 int digits = n / 10;
  30.                 string outputd = c[digits];
  31.                 string outputun = d[units];
  32.                 if (n % 10 == 0)
  33.                 {
  34.                     Console.WriteLine("{0}", outputd);
  35.                 }
  36.                 else
  37.                     Console.WriteLine("{0} {1}", outputd, outputun);
  38.             }
  39.  
  40.             else if (n > 10 && n < 20)
  41.             {
  42.                 int units1 = n % 10;
  43.                 string oout = b[units1];
  44.                 Console.WriteLine(oout);
  45.             }
  46.  
  47.             else if (n % 10 == 0 && n < 100)
  48.             {
  49.                 int desetici = (n / 10);
  50.                 string desetki = c[desetici];
  51.                 Console.WriteLine(desetki);
  52.             }
  53.  
  54.             else if (n == 100)
  55.             {
  56.                 Console.WriteLine("one hundred");
  57.             }
  58.             else
  59.                 Console.WriteLine("invalid number");
  60.  
  61.         }
  62.  
  63.     }
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top