找传奇、传世资源到传世资源站!

C# 找公倍数(两个数整除、三个数整除)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

能同时被两个或者三个整数整除的数值
from clipboard
from clipboard
using System;using System.Windows.Forms;namespace A4{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void calculateButton1_Click(object sender, EventArgs e) { outputBox1.Text = ""; GetNum_1(); CalculateDivisor_1(); } private void calculateButton2_Click(object sender, EventArgs e) { outputBox2.Text = ""; GetNum_2(); CalculateDivisor_2(); } private int startNum; private int endNum; private int firstNum; private int secondNum; private int thirdNum; private void GetNum_1() { startNum = int.Parse(startNumBox1.Text); endNum = int.Parse(endNumBox1.Text); firstNum = int.Parse(firstNumBox1.Text); secondNum = int.Parse(secondNumBox1.Text); } private void GetNum_2() { startNum = int.Parse(startNumBox2.Text); endNum = int.Parse(endNumBox2.Text); firstNum = int.Parse(firstNumBox2.Text); secondNum = int.Parse(secondNumBox2.Text); thirdNum = int.Parse(thirdNumBox2.Text); } private void CalculateDivisor_1() { int nextLine = 0; outputBox1.Text = "在" startNum "和" endNum "之间能被" firstNum "和" secondNum "整除的数有:" Environment.NewLine; for (int i = startNum; i <= endNum; i ) { if (i % firstNum == 0 && i % secondNum == 0) { outputBox1.Text = (i "\t"); nextLine ; }if (nextLine == 4) { outputBox1.Text = Environment.NewLine; nextLine = 0; } } } private void CalculateDivisor_2() { int nextLine = 0; outputBox2.Text = "在" startNum "和" endNum "两个数之间能被" firstNum "和" secondNum "以及" thirdNum "整除的数有:" Environment.NewLine; for (int i = startNum; i <= endNum; i ) { if (i % firstNum == 0 && i % secondNum == 0 && i % thirdNum == 0) { outputBox2.Text = (i "\t"); nextLine ; }if (nextLine == 4) { outputBox2.Text = Environment.NewLine; nextLine = 0; } } } private void startNumBox1_TextChanged(object sender, EventArgs e) { } private void label7_Click(object sender, EventArgs e) { } private void groupBox3_Enter(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { this.Close(); } private void endbutton2_Click(object sender, EventArgs e) { this.Close(); } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复