求一系列数的和.txt
来自「最常用的50个经典程序」· 文本 代码 · 共 26 行
TXT
26 行
using System;
class Class1
{
public static int x;
public static int y;
public static long temp=0;
public static long sum=0;
public static void Main()
{
Console.WriteLine ("请输入所要求这一系列数的和的个数:");
x=int.Parse (Console.ReadLine ());
Console.WriteLine ("请输入这一系列数的基数:");
y=int.Parse (Console.ReadLine ());
for(int i=1;i<=x;i++)
{
int temp=y;
for(int j=1;j<i;j++)
{
temp=temp*10+y;
}
sum+=temp;
}
Console.WriteLine (sum);
Console.Read();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?