3+33+333(网上找的,仅自用,非原创)

Console.WriteLine("请输入需要计算的数");
int a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入项数");
int n = Convert.ToInt32(Console.ReadLine());
double k=0, m = 0;
for (int i = 1; i <= n; i++)
{
k += a*(double)Math.Pow(10, i - 1);
m += k;
}
Console.WriteLine(m);
Console.ReadLine();

posted @ 2018-04-07 14:31  v123ve  阅读(353)  评论(0)    收藏  举报