//编程序功能是输入一个长整数,求各位数字的平方和s。如果输入的是负数,求其相反数的各位数字的平方和。
//例如:输入-123,输出14。(用while或do-while语句实现)
using System;
namespace 各个数字和
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入一个数字:");
int x =Math.Abs( Convert.ToInt32( Console.ReadLine ()));
int y = 0,x2=x;
while(x>0)
{
x2 = x % 10;
y = y + x2 * x2;
x = x / 10;
}
Console.WriteLine("你得到的数字和是:{0}",y);
}
}
}