作业帮 > 综合 > 作业

用C#写一个程序,输入5个数,确定和显示正数,负数和0的个数

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/03/29 23:38:18
用C#写一个程序,输入5个数,确定和显示正数,负数和0的个数
int 正= 0,负 = 0,零 = 0;
if (Convert.ToInt32 ( this.textBox1.Text.ToString().Trim())==0)
零 += 1;
else if (Convert.ToInt32 ( this.textBox1.Text.ToString().Trim())>0)
正 += 1;
else
负 += 1;
if (Convert.ToInt32(this.textBox2.Text.ToString().Trim()) == 0)
零 += 1;
else if (Convert.ToInt32(this.textBox2.Text.ToString().Trim()) > 0)
正 += 1;
else
负 += 1;
if (Convert.ToInt32(this.textBox3.Text.ToString().Trim()) == 0)
零 += 1;
else if (Convert.ToInt32(this.textBox3.Text.ToString().Trim()) > 0)
正 += 1;
else
负 += 1;
if (Convert.ToInt32(this.textBox4.Text.ToString().Trim()) == 0)
零 += 1;
else if (Convert.ToInt32(this.textBox4.Text.ToString().Trim()) > 0)
正 += 1;
else
负 += 1;
if (Convert.ToInt32(this.textBox5.Text.ToString().Trim()) == 0)
零 += 1;
else if (Convert.ToInt32(this.textBox5.Text.ToString().Trim()) > 0)
正 += 1;
else
负 += 1;
MessageBox.Show("正:" + 正 + "负:" + 负 + "零:" + 零);