erehh

Untitled

Oct 28th, 2022
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. using System.Runtime.CompilerServices;
  2.  
  3. namespace INFINIT
  4. {
  5. class program
  6. {
  7. static string answ1, answ2; //Entered numbers by the user
  8. static char[] charArr1; //Entered numbers char arrays
  9. static char[] charArr2; //Entered numbers char arrays
  10.  
  11.  
  12.  
  13. static void Main()
  14. {
  15. Start();
  16.  
  17.  
  18.  
  19. }
  20.  
  21. static void Start()
  22. {
  23. Introduction();
  24.  
  25. getNumbers();
  26.  
  27. stringToChar1();
  28. stringToChar2();
  29.  
  30. printNumber(charArr1);
  31. printNumber(charArr2);
  32.  
  33.  
  34.  
  35. }
  36.  
  37. static void Introduction()
  38. {
  39. Console.WriteLine("Hello. This is an INFINIT program.");
  40. Console.WriteLine("You will have to enter 2 numbers, that are larger than int or long datatype. ");
  41. Console.WriteLine("Int (- 2 147 483 648 : 2 147 483 647)");
  42. Console.WriteLine("Long (-9 223 372 036 854 775 808 : 9 223 372 036 854 775 807)");
  43. Console.WriteLine();
  44.  
  45. }
  46.  
  47. static void getNumbers()
  48. {
  49. Console.Write("Enter the first number: ");
  50. answ1 = Console.ReadLine();
  51. Console.WriteLine();
  52. Console.Write("Enter the second number: ");
  53. answ2 = Console.ReadLine();
  54. }
  55.  
  56.  
  57. static void stringToChar1()
  58. {
  59. charArr1 = new char[answ1.Length];
  60. charArr1 = answ1.ToCharArray();
  61. }
  62.  
  63. static void stringToChar2()
  64. {
  65. charArr2 = new char[answ2.Length];
  66. charArr2 = answ2.ToCharArray();
  67. }
  68.  
  69. static void printNumber(char[]arr)
  70. {
  71. int index=arr.Length-1;
  72. Console.WriteLine("Presented in the powers of 10: ");
  73. for (int i = 0; i < arr.Length; i++)
  74. {
  75. if(i+1==arr.Length)
  76. Console.Write($"{arr[i]}*10^{index--} ");
  77. else if (arr.Length > i + 1)
  78. Console.Write($"{arr[i]}*10^{index--} + ");
  79.  
  80. }
  81. Console.WriteLine();
  82. }
  83.  
  84.  
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment