> 其他 >
C#阶乘问题
计算阶乘.比如用户在TextBox里输入7,就会显示 :
The factorial of 1 is 1
The factorial of 2 is 2
The factorial of 3 is 6
The factorial of 4 is 24
The factorial of 5 is 120
The factorial of 6 is 720
The factorial of 7 is 5040
.
这是我的代码,这是乘方,怎么写阶乘?
//Declare variables
int numRow =0;
int i = 0;
public calculateButton()
{
InitializeComponent();
}
private void buttonCalculate_Click(object sender,EventArgs e)
{
if (int.TryParse(textBoxnumber.Text,out numRow) == true)
{
for (int i = 1; i
人气:479 ℃ 时间:2020-04-08 01:13:31
解答
在最前面加:
double sum = 1;

int i = 0;一起


for语句内修改:
for (int i = 1; i
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版