} // ненужен public static Drobi operator ^(Drobi one, int n) { Drobi result = new Drobi(1, 1); if (n > 0) { for (int i = 0; i < n; i++) { result.x = result.x * one.x; result.y = result.y * one.y; } } else if (n < 0) { for (int i = 0; i < Math.Abs(n); i++) { result.x = result.x * one.x; result.y = result.y * one.y; } int temp = result.x; result.x = result.y; result.y = temp; } return(result); }
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 Dele(Drobi drobi) { if (drobi.y == 0) { drobi.y = 1; } Drobi result = new Drobi(drobi.y, drobi.x); Mult(result); } // ненужен
static void Main(string[] args) { Drobi a = new Drobi("6/9"); Drobi b = new Drobi(6, 3); Console.WriteLine(a < b); Console.WriteLine((double)a); //int q = 1; //q += 3; Console.ReadLine(); }
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 static Drobi operator -(Drobi one, Drobi two) { Drobi result = new Drobi(); if (one.y == two.y) { result.x = one.x - two.x; result.y = one.y; } else { result.x = one.x * two.y - two.x * one.y; result.y = one.y * two.y; } return(result); }
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(); } // ненужен