Advertisement
MeliDragon

Untitled

Mar 7th, 2023
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics.CodeAnalysis;
  4. using System.Diagnostics.Tracing;
  5. using System.Linq;
  6. using System.Text;
  7. namespace BigNumbers
  8. {
  9. internal class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] length = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14. string inputOne = Console.ReadLine();
  15. string inputTwo = Console.ReadLine();
  16.  
  17. int n = 0;
  18. int m = 0;
  19. if (length[0] > length[1])
  20. {
  21. n = length[0];
  22. m = length[1];
  23. }
  24. else
  25. {
  26. n = length[1];
  27. m = length[0];
  28. string temp = inputOne;
  29. inputOne = inputTwo;
  30. inputTwo = temp;
  31. }
  32. int[] first = inputOne.Split(' ').Select(int.Parse).ToArray();
  33. int[] second = inputTwo.Split(' ').Select(int.Parse).ToArray();
  34. List<int> result = new List<int>();
  35. int left = 0;
  36. int sum = 0;
  37. for (int i = 0; i < n; i++)
  38. {
  39. if (i<m)
  40. {
  41. sum += first[i] + second[i];
  42. if (sum>9)
  43. {
  44. left = 1;
  45. sum = sum % 10;
  46. }
  47. result.Add(sum);
  48. sum = 0;
  49. }
  50. else
  51. {
  52. sum = first[i];
  53. result.Add(sum);
  54. }
  55. if (left == 1)
  56. {
  57. sum=1;
  58. left = 0;
  59. }
  60. if (i == n-1 && left == 1)
  61. {
  62. result.Add(left);
  63. }
  64. }
  65.  
  66. Console.WriteLine(String.Join(" ",result));
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement