Exemple #1
0
        static void Main(string[] args)
        {
            string     s   = Console.ReadLine();
            string     c   = s.Split(' ')[0];
            string     d   = s.Split(' ')[1];
            int        a   = int.Parse(c.Split('/')[0]);
            int        b   = int.Parse(c.Split('/')[1]);
            int        a1  = int.Parse(d.Split('/')[0]);
            int        b1  = int.Parse(d.Split('/')[1]);
            complexnum q   = new complexnum(a, b);
            complexnum w   = new complexnum(a1, b1);
            complexnum res = q + w;

            Console.WriteLine(res);
            FileStream      fs = new FileStream("data.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
            BinaryFormatter bf = new BinaryFormatter();

            bf.Serialize(fs, res);
            fs.Close();
            bf = new BinaryFormatter();
            FileStream fss = new FileStream("data.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
            complexnum v   = bf.Deserialize(fss) as complexnum;

            Console.WriteLine(v);
            Console.ReadKey();
        }
Exemple #2
0
        public static complexnum operator +(complexnum c1, complexnum c2)
        {
            int        dvd = c1.b * c2.b;
            int        dvs = c1.a * c2.b + c2.a * c1.b;
            complexnum c   = new complexnum(dvs, dvd);

            c.Simplify();
            return(c);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            string     s   = Console.ReadLine();
            string     c   = s.Split(' ')[0];
            string     d   = s.Split(' ')[1];
            int        a   = int.Parse(c.Split('/')[0]);
            int        b   = int.Parse(c.Split('/')[1]);
            int        a1  = int.Parse(d.Split('/')[0]);
            int        b1  = int.Parse(d.Split('/')[1]);
            complexnum q   = new complexnum(a, b);
            complexnum r   = new complexnum(a1, b1);
            complexnum res = q + r;


            Console.WriteLine(res);
            Console.ReadKey();
        }