https://pastein.ru/t/CI

  скопируйте уникальную ссылку для отправки


using System;

namespace mathoperation
{
    class Program
    {
        static int[] toarr(string n1)
        {
            int[] ret = new int[n1.Length+1];
            for (int i= n1.Length-1; i >=0; i--)
            {
                ret[i]= Convert.ToInt32(n1[n1.Length-i-1].ToString());
            }
            return ret;
        }
        static void plusvosm(string n1, string n2)
        {

            int[] ch1 = toarr(n1);
            int[] ch2 = toarr(n2);
            if (ch1.Length < ch2.Length)
            {
                int[] p = ch2;
                ch2 = ch1;
                ch1 = p;
            }
            int[] res = new int[Math.Max(ch1.Length, ch2.Length)];
            int per;
            int raz = 0;
            for (int i = 0; i < Math.Min(ch1.Length,ch2.Length); i++)
            {
                per = ch1[i] + ch2[i] + raz;
                raz = 0;
                if (per >= 8)
                {
                    per -= 8;
                    raz = 1;
                }
                res[i] = per; 
            }
            for (int i = Math.Min(ch1.Length, ch2.Length); i < Math.Max(ch1.Length, ch2.Length); i++)
            {
                per = ch1[i] +  raz;
                raz = 0;
                if (per >= 8)
                {
                    per -= 8;
                    raz = 1;
                }
                res[i] = per;
            }
            for (int i = res.Length-1; i >=0; i--)
            {
                Console.Write(res[i]);
            }
            


        }


        static void Main(string[] args)
        {
            plusvosm("4455", "42546");
        }
    }
}