public static Rac operator *(Rac r1, Rac RacObj) { Rac RacResult = new Rac(r1.n * RacObj.n, r1.d * RacObj.d); RacResult.set_mcd(RacResult.calc_mcd()); RacResult.simplificar(); return(RacResult); }
private void button1_Click(object sender, EventArgs e) { //int f = dataGridView1.CurrentCellAddress.Y; //int c = dataGridView1.CurrentCellAddress.X; //textBox1.Text = c.ToString(); //textBox2.Text = f.ToString(); //object valorCelda = dataGridView1.Rows[ Convert.ToInt32(textBox2.Text)].Cells[Convert.ToInt32(textBox1.Text)].Value; //textBox3.Text = valorCelda.ToString(); //String cad= valorCelda.ToString(); /*int index = cad.IndexOf("/"); * int num = Convert.ToInt32(cad.Substring(0,index)); * int den = Convert.ToInt32(cad.Substring(index+1)); * textBox3.Text = den.ToString(); */ //int index, num, den; //Rac[] R = new Rac[6]; //for(int j = 1; j <= 6; j++) //{ // valorCelda = dataGridView1.Rows[Convert.ToInt32(textBox2.Text)].Cells[j].Value; // cad = valorCelda.ToString(); // index = cad.IndexOf("/"); // num = Convert.ToInt32(cad.Substring(0, index)); // den = Convert.ToInt32(cad.Substring(index + 1)); // R[j - 1] = new Rac(num,den); //} int colPivote = Convert.ToInt32(textBox1.Text); int colDisponibilidad = 6; int num, den, index; object valorCelda; Rac RacNum = new Rac(), RacDen = new Rac(), RacQ = new Rac(); float q; for (int i = 1; i <= 3; i++) { valorCelda = dataGridView1.Rows[i].Cells[colDisponibilidad].Value; index = valorCelda.ToString().IndexOf("/"); num = Convert.ToInt32(valorCelda.ToString().Substring(0, index)); den = Convert.ToInt32(valorCelda.ToString().Substring(index + 1)); RacNum.set_n(num); RacNum.set_d(den); valorCelda = dataGridView1.Rows[i].Cells[colPivote].Value; index = valorCelda.ToString().IndexOf("/"); num = Convert.ToInt32(valorCelda.ToString().Substring(0, index)); den = Convert.ToInt32(valorCelda.ToString().Substring(index + 1)); RacDen.set_n(num); RacDen.set_d(den); if ((RacDen.get_n() != 0) && (RacDen.get_d() != 0)) { RacQ = RacNum / RacDen; num = RacQ.get_n(); den = RacQ.get_d(); q = (float)num / (float)den; dataGridView1.Rows[i].Cells[colDisponibilidad + 1].Value = q.ToString(); } } }
public static Rac operator /(Rac r1, Rac RacObj) { //Rac RacR; Rac RacResult = new Rac(); RacResult.n = r1.n * RacObj.d; RacResult.d = r1.d * RacObj.n; RacResult.set_mcd(RacResult.calc_mcd()); RacResult.simplificar(); return(RacResult); }