Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 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 CSharpTwoExam
  8. {
  9.  
  10.  
  11. class Program
  12. {
  13. public static int numBase = 19;
  14. static void Main(string[] args)
  15. {
  16.  
  17.  
  18.  
  19. string[] input = Console.ReadLine().Split();
  20. string result = String.Empty;
  21. string currentNumber = String.Empty;
  22. string[] resultNumber;
  23. int theResult = 0;
  24.  
  25. int mainResult = 0;
  26.  
  27. for (int k = 0; k < input.Length; k++)
  28. {
  29. for (int i = 0; i < input[k].Length; i++)
  30. {
  31. currentNumber += getCurrentNumber(input[k][i].ToString()) + " ";
  32.  
  33. }
  34. resultNumber = currentNumber.Split();
  35.  
  36. for (int i = resultNumber.Length - 2; i >= 0; i--)
  37. {
  38. theResult += int.Parse(resultNumber[i]) * powerOfNineteen(resultNumber.Length - i - 2);
  39. }
  40.  
  41. mainResult += theResult;
  42. theResult = 0;
  43. currentNumber = String.Empty;
  44.  
  45. }
  46. string nineteenResult = String.Empty;
  47. int saveMain = mainResult;
  48. while (mainResult > 0)
  49. {
  50. int digit = mainResult % 19;
  51. nineteenResult += checkNuber(digit.ToString());
  52. mainResult /= 19;
  53. }
  54. char[] theResultBro = nineteenResult.ToCharArray();
  55. Array.Reverse(theResultBro);
  56. Console.WriteLine( new string(theResultBro) + " = " + saveMain);
  57. }
  58. public static string checkNuber(string number)
  59. {
  60. string theNumber = String.Empty;
  61. string alphabeth = "abcdefghijklmnopqrs";
  62. for (int i = 0; i < alphabeth.Length; i++)
  63. {
  64. if (number == i.ToString())
  65. {
  66. theNumber = alphabeth[i].ToString();
  67. }
  68. }
  69. return theNumber;
  70. }
  71. public static string getCurrentNumber(string input)
  72. {
  73. string alphabeth = "abcdefghijklmnopqrs";
  74. string result = string.Empty;
  75. for (int i = 0; i < input.Length; i++)
  76. {
  77. for (int j = 0; j < alphabeth.Length; j++)
  78. {
  79. if (input[i] == alphabeth[j])
  80. {
  81. result = j.ToString();
  82. break;
  83. }
  84. }
  85. }
  86. return result;
  87.  
  88. }
  89. public static int powerOfNineteen(int power)
  90. {
  91. int result = 1;
  92. for (int i = 0; i < power; i++)
  93. {
  94. result *= 19;
  95. }
  96. return result;
  97. }
  98.  
  99. }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement