使用while循环设计一个程序,用户在文本框中输入一个整数n,单击“筛选素数”按钮,程序将找出3~n的所有素数并在列表框中输出。
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("请输入一个正整数", "提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); return; } int n = int.Parse(textBox1.Text); int a = 1; for (int i = 3; i
107.5KB
文件大小:
评论区