public VeryLongNumber add(VeryLongNumber n) { StringBuilder n1 = new StringBuilder(Reverse(this.value)); StringBuilder n2 = new StringBuilder(Reverse(n.value)); if (n1.Length > n2.Length) { while (n2.Length != n1.Length) { n2.Append('0'); } } else { while (n1.Length != n2.Length) { n1.Append('0'); } } var ost = 0; var chislo = 0; StringBuilder new_number = new StringBuilder(""); for (int i = 0; i < Math.Max(n1.Length, n2.Length); i++) { n1[i] = Convert.ToChar((Convert.ToInt32(Convert.ToString(n1[i])) + Convert.ToInt32(Convert.ToString(n2[i]))) % 10); if((Convert.ToInt32(Convert.ToString(n1[i])) + Convert.ToInt32(Convert.ToString(n2[i])) > 10); } }
public static void Main(string[] args) { List<SimpleLongNumber> simpleLongNumbers = new List<SimpleLongNumber>(); List<VeryLongNumber> veryLongNumbers = new List<VeryLongNumber>(); for (int i = 0; i < Convert.ToInt32(Console.ReadLine()); i++) { VeryLongNumber n = new VeryLongNumber(Console.ReadLine()); if (n.IsSimpleLongNumber()) { SimpleLongNumber n_sLN = new SimpleLongNumber(long.Parse(n.value)); simpleLongNumbers.Add(n_sLN); } else { veryLongNumbers.Add(n); } } VeryLongNumber sum = new VeryLongNumber(); }