Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp19
- {
- class Program
- {
- static void Main(string[] args)
- {
- myComplex c1 = new myComplex(4, 3.3);
- Console.WriteLine("Модуль исходного комплексного числа = " +
- c1.Mod());
- while (c1)
- {
- Console.Write("c1 => "); display(c1);
- c1--;
- }
- Console.WriteLine("Модуль полученного числа = " +
- c1.Mod());
- Console.WriteLine("Число принадлежит кругу с радиусом 1.");
- Console.ReadKey();
- }
- static void display(myComplex cs)
- {
- Console.WriteLine("real=" + cs.re + ", image=" + cs.im);
- }
- }
- class myComplex
- {
- public double re, im;
- public myComplex(double xre, double xim)
- { re = xre; im = xim; }
- public static myComplex operator --(myComplex mc)
- { mc.re--; mc.im--; return mc; }
- public static myComplex operator ++(myComplex mc)
- { mc.re++; mc.im++; return mc; }
- public double Mod() { return Math.Abs(re * re + im * im); }
- static public bool operator true(myComplex f)
- {
- if (f.Mod() > 1.0) return true;
- else return false;
- }
- static public bool operator false(myComplex f)
- {
- if (f.Mod() <= 1.0) return true;
- else return false;
- }
- public static myComplex operator +(myComplex a, myComplex b)
- {
- return new myComplex(a.re + b.re, a.im + b.im);
- }
- public static myComplex operator -(myComplex a, myComplex b)
- {
- return new myComplex(a.re - b.re, a.im - b.im);
- }
- public static myComplex operator *(myComplex a, myComplex b)
- {
- return new myComplex(a.re * b.re - a.im * b.im, a.re * b.im + a.im * b.re);
- }
- public static myComplex operator /(myComplex a, myComplex b)
- {
- return new myComplex((a.re * b.re + a.im + b.im) / (b.re * b.re + b.im * b.im), (a.im * b.re - a.re * b.im) / (b.re * b.re + b.im * b.im));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement