public Polynmial2 Mod(Polynmial2 polynmial) { if (a == 0 && polynmial.A != 0) { return(new Polynmial2(this)); } else if (a != 0 && polynmial.A != 0) { return(new Polynmial2(0, b - (polynmial.B * a) / polynmial.A, c - (polynmial.C * a) / polynmial.A)); } else if (a != 0 && polynmial.A == 0) { if (polynmial.B != 0) { return(new Polynmial2(0, 0, c - ((b - (polynmial.C * a) / polynmial.B) * polynmial.C) / polynmial.B)); } else { if (polynmial.C == 0) { throw new DivideByZeroException(); } return(new Polynmial2(0, 0, 0)); } } else // a == 0 && polynomal.A == 0 { if (b == 0 && polynmial.B == 0) { if (polynmial.C == 0) { throw new DivideByZeroException(); } return(new Polynmial2(0, 0, 0)); } else if (b != 0 && polynmial.B == 0) { if (polynmial.C == 0) { throw new DivideByZeroException(); } return(new Polynmial2(0, 0, 0)); } else if (b == 0 && polynmial.B != 0) { return(new Polynmial2(this)); } else // b != 0 && polynomal.B != 0 { return(new Polynmial2(0, 0, c - (b * polynmial.C) / polynmial.B)); } } }
static void Main(string[] args) { Random ran = new Random(); Polynmial2 a = new Polynmial2(ran.Next(-100, 100), ran.Next(-100, 100), ran.Next(-100, 100)); Polynmial2 b = new Polynmial2(ran.Next(-100, 100), ran.Next(-100, 100), ran.Next(-100, 100)); Console.WriteLine(a); Console.WriteLine(b); Polynmial2 c = new Polynmial2(a % b); Console.WriteLine(c); Console.ReadKey(); }
public Polynmial2 Removal(Polynmial2 polynmial) { return(new Polynmial2(a - polynmial.A, b - polynmial.B, c - polynmial.C)); }
public Polynmial2 Add(Polynmial2 polynmial) { return(new Polynmial2(a + polynmial.A, b + polynmial.B, c + polynmial.C)); }
public Polynmial2(Polynmial2 polynmial) { a = polynmial.A; b = polynmial.B; c = polynmial.C; }