Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace task_4
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] arr1 = Console.ReadLine()
- .Split()
- .Select(s => int.Parse(s))
- .ToArray();
- int[] arr2 = Console.ReadLine()
- .Split()
- .Select(s => int.Parse(s))
- .ToArray();
- int n1 = arr1.Length;
- int n2 = arr2.Length;
- int n = Math.Max(n1, n2);
- int[] sum = new int[n];
- int[] local = new int[n];
- if (n1 == n2)
- {
- for (int i = 0; i < n; i++)
- {
- sum[i] = arr1[i] + arr2[i];
- }
- string result = string.Join(" ", sum);
- Console.WriteLine(result);
- }
- else if (n1 < n2)
- {
- int i, j = 0;
- for (i = 0; j <= n1; j++, i++)
- {
- if (i == n)
- {
- break;
- }
- if (j == n1)
- {
- j = 0;
- }
- local[i] = arr1[j];
- sum[i] = local[i] + arr2[i];
- }
- string result = string.Join(" ", sum);
- Console.WriteLine(result);
- }
- else if (n1 > n2)
- {
- int i, j = 0;
- for (i = 0; j <= n2; j++, i++)
- {
- if (i == n)
- {
- break;
- }
- if (j == n2)
- {
- j = 0;
- }
- local[i] = arr2[j];
- sum[i] = local[i] + arr1[i];
- }
- string result = string.Join(" ", sum);
- Console.WriteLine(result);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement