Horje
add two large numbers Code Example
add two large numbers
public static string AddTwoNumber(string x, string y)
{
    var X = x.ToCharArray().ToList().Select(s => Convert.ToInt32(s.ToString())).ToList();
    var Y = y.ToCharArray().ToList().Select(s => Convert.ToInt32(s.ToString())).ToList();

    X.Reverse();
    Y.Reverse();

    if (X.Count > Y.Count)
    {
        return Add(X, Y);
    }
    else
    {
        return Add(Y, X);
    }
}
public static string Add(List<int> first, List<int> second)
{
    var remainder = 0;
    var list = new List<int>();
    for (int i = 0; i < first.Count; i++)
    {
        var temp = 0;
        if(i<second.Count)
        {
            temp = second[i];
        }
        var num = temp + first[i] + remainder;
        var inString = num.ToString();

        if (inString.Length > 1)
        {
            list.Add(Convert.ToInt32(inString[1].ToString()));
            remainder = Convert.ToInt32(inString[0].ToString());
        }
        else
        {
            list.Add(Convert.ToInt32(inString[0].ToString()));
            remainder = 0;
        }
    }
    list.Reverse();
    var str = string.Empty;
    foreach (var item in list)
    {
        str += item;
    }
    return str;
}




Csharp

Related
how to change argument of function in f# Code Example how to change argument of function in f# Code Example
c# register write value Code Example c# register write value Code Example
Dyanmically create datatable in c# Code Example Dyanmically create datatable in c# Code Example
C# show text in another form Code Example C# show text in another form Code Example
unity follow object Code Example unity follow object Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10