private RAT MakeRAT(int m, int n) { int a = (int)(Math.Pow(m, 2) - Math.Pow(n, 2)); int b = 2 * m * n; int c = (int)(Math.Pow(m, 2) + Math.Pow(n, 2)); RAT result = new RAT(); result.a = a; result.b = b; result.c = c; return(result); }
private void button1_Click(object sender, EventArgs e) { int total = Convert.ToInt32(this.textBox1.Text); int _m = 0, _n = 0; Random r = new Random(); for (int i = 0; i <= total; i++) { _m = r.Next(0, total); _n = r.Next(0, total); do { _m = r.Next(0, total); _n = r.Next(0, total); }while (!isRightValue(_m, _n)); RAT result = MakeRAT(_m, _n); this.textBox2.Text += ("(" + result.a.ToString() + ", " + result.b.ToString() + ", " + result.c.ToString() + ")\r\n"); } }