using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication8
{
class Program
{
static void Main(string[] args)
{
ConsoleKeyInfo c;
do
{
System.Console.WriteLine("请输入一个大于100的整数");
; string number = Console.ReadLine();
int.TryParse(number, out a);
//Console.WriteLine("{0}", a);
];
;
)
{
b[cnt++] = a % ;
a /= ;
}
Console.WriteLine("该整数一共有{0}位", cnt);
;
Console.Write("实现思路1: 每一位的值为");
; i >= ; --i)
{
Console.Write("{0}、", b[i]);
sum += b[i];
}
Console.Write(", 这些位之和为{0}", sum);
Console.WriteLine("");
Console.Write("实现思路2: 每一位的值为");
sum = ;
; i < number.Length; ++i)
{
Console.Write("{0}、", number[i]);
sum += number[i] - ';
}
Console.Write(", 这些位之和为{0}", sum);
Console.WriteLine("");
Console.WriteLine("按回车键退出,其他键继续!");
c = Console.ReadKey();
} while (c.Key != ConsoleKey.Enter);
}
}
}