Advertisement
Guest User

Untitled

a guest
Feb 29th, 2016
1,366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 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 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[] { "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)
  21. {
  22. string outun = a[n-1];
  23. Console.WriteLine(outun);
  24. }
  25.  
  26. else if (n > 10 && 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. Console.WriteLine("{0} {1}", outputd, outputun);
  33. }
  34.  
  35. else if (n > 10 && n < 20)
  36. {
  37. int units1 = n % 10;
  38. string oout = b[units1];
  39. Console.WriteLine(oout);
  40. }
  41.  
  42. else if (n % 10 == 0 && n < 100)
  43. {
  44. int desetici = (n / 10);
  45. string desetki = c[desetici];
  46. Console.WriteLine(desetki);
  47. }
  48.  
  49. else if (n / 100 == 1)
  50. {
  51. if (n < 101) {
  52. int stotici = n / 100;
  53. string sto = a[stotici - 1];
  54. Console.WriteLine("{0} {1}", sto, h);
  55. }
  56. }
  57.  
  58. if (n>100)
  59. Console.WriteLine("invalid number");
  60.  
  61. }
  62.  
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement