本文介绍了C#简单析因程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void button1_Click(object sender, EventArgs e)
{
String UserNumber = this.textBox1.Text;
int NewUserNumber = Convert.ToInt32(UserNumber);
int result = 0;
int second = 0;
while (NewUserNumber >= 1)
{
result = NewUserNumber * (NewUserNumber - 1);
NewUserNumber--;
}
String i = Convert.ToString(result);
this.textBox2.Text = i;
}
}
虽然我知道这对我来说是家庭作业,但我被困住了.我真的真的不想解决这个问题,我想自己解决.
While I understand this is homework for me, I am stuck. I really really don't want this solved, I want to do it myself.
我不明白为什么它不起作用.不管我输入什么,它都会输出2.
I don't understand why it's not working.. It's outputting 2 no matter what I put in.
我可以用Java轻松地做到这一点,但是转换就交给我了.
I could do this in Java easily but the converting gets to me..
任何帮助都会很棒.
推荐答案
您的问题不在转换中.请看
Your problem is not in the conversion. Please look at
result = NewUserNumber * (NewUserNumber - 1);
这篇关于C#简单析因程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!