public void Power(int n) { Drobi result = new Drobi(1, 1); if (n > 0) { for (int i = 0; i < n; i++) { result.x = result.x * x; result.y = result.y * y; } } else if (n < 0) { for (int i = 0; i < Math.Abs(n); i++) { result.x = result.x * x; result.y = result.y * y; } int temp = result.x; result.x = result.y; result.y = temp; } result.Sokr(); result.Show(); } // ненужен
public static Drobi operator /(int n, Drobi two) { Drobi result = new Drobi(); result.x = two.y * n; result.y = two.x * 1; result.Sokr(); return(result); }
public static Drobi operator /(Drobi one, int n) { Drobi result = new Drobi(); result.x = one.x * 1; result.y = one.y * n; result.Sokr(); return(result); }
} // ненужен public static Drobi operator /(Drobi one, Drobi two) { Drobi result = new Drobi(); result.x = one.x * two.y; result.y = one.y * two.x; result.Sokr(); return(result); }
public static Drobi operator *(int n, Drobi two) { Drobi result = new Drobi(); result.x = n * two.x; result.y = 1 * two.y; result.Sokr(); return(result); }
public void Mult(Drobi drobi) // ненужен { Drobi result = new Drobi(); if (drobi.y == 0) { drobi.y = 1; } result.x = x * drobi.x; result.y = y * drobi.y; result.Sokr(); result.Show(); }
public static bool operator ==(Drobi one, Drobi two) { Drobi oneCopy = new Drobi(one.x, one.y); Drobi twoCopy = new Drobi(two.x, two.y); oneCopy.Sokr(); twoCopy.Sokr(); if (oneCopy.x == twoCopy.x && oneCopy.y == twoCopy.y) { return(true); } return(false); }
public void Minus(Drobi drobi) { Drobi result = new Drobi(); if (y == drobi.y) { result.x = x - drobi.x; result.y = y; } else { result.x = x * drobi.y - drobi.x * y; result.y = y * drobi.y; } result.Sokr(); result.Show(); } // ненужен