Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- static int[] ar1 = new int[] { 4, 5, 3, 0, 1 };
- static int[] ar2 = new int[] { 5, 7, 8, 1, 2 };
- static int[] ar3 = new int[10];
- static void Sum()
- {
- int c = 0;
- int i = 0;
- while (i < ar1.Length && i< ar2.Length)
- {
- int d = ar1[i] + ar2[i];
- if (d >= 10)
- {
- d %= 10;
- ar3[i] = d + c;
- c = 1;
- }
- else
- {
- ar3[i] = d + c;
- c = 0;
- }
- }
- if (c == 1) ar3[i] = 1;
- for (int j = 0; j< i ; j++)
- {
- Console.Write(ar3[j]);
- }
- Console.WriteLine();
- }
- static void Ar(int[] a)
- {
- for (int i = 0; i < a.Length; i++)
- Console.Write(a[i]);
- }
- static void Main(string[] args)
- {
- Ar(ar1);
- Console.WriteLine();
- Ar(ar2);
- Sum();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement