DotNetCSharp
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace AnyNumberPlus2
6 {
7 class Program
8 {
9 static void Main(string[] args)
10 {
11 string num1 = "0" + "145435435";
12 string num2 = "0" + "99";
13 string resault = num1.Length <num2.Length ? num1=num1.PadLeft(num2.Length,\'0\') : num2=num2.PadLeft(num1.Length,\'0\');
14 int flag = 0;
15 resault = "";
16 for (int i = num1.Length - 1; i >= 0; i--)
17 {
18 string res = ((int.Parse(num1[i].ToString()) + int.Parse(num2[i].ToString())) % 10 + flag).ToString();
19 resault = res + resault;
20 flag = (int.Parse(num1[i].ToString()) + int.Parse(num2[i].ToString())) >= 10 ? 1 : 0;
21 }
22 resault = resault.StartsWith("0") == true ? resault.Substring(1, resault.Length - 1) : resault;
23 Console.WriteLine(resault);
24 Console.ReadLine();
25 }
26 }
27 }

分类:

技术点:

相关文章:

  • 2021-08-19
  • 2021-11-21
  • 2021-07-17
  • 2021-11-21
  • 2021-04-23
  • 2021-04-26
  • 2021-11-18
猜你喜欢
  • 2021-11-21
  • 2021-12-19
  • 2021-11-21
  • 2021-11-21
  • 2021-11-21
  • 2021-12-01
相关资源
相似解决方案