标签:ref tostring tle str 情况 toc 程序 dex 大于
using System; using System.Text; namespace TestSum { class Program { static void Main(string[] args) { long a = 112233445566778899; long b = 998877665544332211; //long a = 123; //long b = 29; char[] ac = a.ToString().ToCharArray(); char[] bc = b.ToString().ToCharArray(); StringBuilder result = new StringBuilder(); if(ac.Length>=bc.Length) { int temp = 0; for (int i = ac.Length - 1, j = bc.Length-1; i>=0; i--,j--) { int indexValue = 0; if (temp == 1) { indexValue++; } int _a = 0, _b = 0; if(j<0) { _b = 0; _a = int.Parse(ac[i].ToString()); } else { _a = int.Parse(ac[i].ToString()); _b = int.Parse(bc[j].ToString()); } if(_a+_b>9) { indexValue+= ((_a + _b-10 )); temp = 1; } else { indexValue+= (_a + _b); temp = 0; } result.Append(indexValue); } } reverse(result.ToString()); Console.ReadKey(); } static void reverse(string result) { for(int i =result.Length-1;i>=0;i--) { Console.Write(result[i]); } } } }
标签:ref tostring tle str 情况 toc 程序 dex 大于
原文地址:http://www.cnblogs.com/kmsfan/p/7471405.html