Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Tracing;
- using System.Linq;
- using System.Text;
- namespace BigNumbers
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int[] length = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- string inputOne = Console.ReadLine();
- string inputTwo = Console.ReadLine();
- int n = 0;
- int m = 0;
- if (length[0] > length[1])
- {
- n = length[0];
- m = length[1];
- }
- else
- {
- n = length[1];
- m = length[0];
- string temp = inputOne;
- inputOne = inputTwo;
- inputTwo = temp;
- }
- int[] first = inputOne.Split(' ').Select(int.Parse).ToArray();
- int[] second = inputTwo.Split(' ').Select(int.Parse).ToArray();
- List<int> result = new List<int>();
- int left = 0;
- int sum = 0;
- for (int i = 0; i < n; i++)
- {
- if (i<m)
- {
- sum += first[i] + second[i];
- if (sum>9)
- {
- left = 1;
- sum = sum % 10;
- }
- result.Add(sum);
- sum = 0;
- }
- else
- {
- sum = first[i];
- result.Add(sum);
- }
- if (left == 1)
- {
- sum=1;
- left = 0;
- }
- if (i == n-1 && left == 1)
- {
- result.Add(left);
- }
- }
- Console.WriteLine(String.Join(" ",result));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement