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 Ex08_8
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        int gcd(int u, int v)
        {
            int r;
            while (v != 0)
            {
                r = u % v;
                u = v;
                v = r;
            }
            return (u);
        }


        private void button1_Click(object sender, EventArgs e)
        {
            int a, b;
            if (textBox1.Text != "" && textBox2.Text != "")
            {
                a = Convert.ToInt32(textBox1.Text);
                b = Convert.ToInt32(textBox2.Text);
                if (a <= 0 || b <= 0)
                {
                    MessageBox.Show(this, "必须输入两个非负整数！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);     
                }
                else
                {
                    textBox3.Text = gcd(a, b).ToString();
                }
            }
            else
            {
                MessageBox.Show(this, "输入的数据不完整！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
    }
}
