using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int a = Convert.ToInt32(textBox1.Text);
int b = Convert.ToInt32(textBox2.Text);
if (a >= b)
{
for (int c = b; c <= b && c > 0; c--)
if (a % c == 0 && b % c == 0)
{
int d=a*b/c;
textBox3.Text = c.ToString();
textBox4.Text = d.ToString();
break;
}
}
if (a < b)
{
for (int c = a; c <= a && c > 0; c--)
if (a % c == 0 && b % c == 0)
{
int d = a*b/c;
textBox3.Text = c.ToString();
textBox4.Text = d.ToString();
break;
}
}
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
}
}
}
最小公倍数最大公约数c#版
5星 · 超过95%的资源 需积分: 21 20 浏览量
2012-03-12
23:20:00
上传
评论 1
收藏 49KB ZIP 举报
Jessiedar
- 粉丝: 0
- 资源: 2