求一题的完整代码?谢过。
设计complex类,完成复数的+、-、*、/运算。 --------------------编程问答-------------------- 自己研究研究表达式解析,一般主要用后缀表达式.如果转化为后缀表达式后,结果也就出来了,关键是你如何转化中缀表达式为后缀表达式.
参照这个看看:
http://baike.baidu.com/view/339689.htm?fr=ala0_1_1
--------------------编程问答-------------------- public struct Complex
{
public int real;
public int imaginary;
public Complex(int real, int imaginary) //constructor
{
this.real = real;
this.imaginary = imaginary;
}
// Declare which operator to overload (+),
// the types that can be added (two Complex objects),
// and the return type (Complex):
public static Complex operator +(Complex c1, Complex c2)
{
return new Complex(c1.real + c2.real, c1.imaginary + c2.imaginary);
}
// Override the ToString() method to display pointA complex number in the traditional format:
public override string ToString()
{
return (System.String.Format("{0} + {1}radius", real, imaginary));
}
}
MSDN上+的例子 --------------------编程问答-------------------- +的算法我知道,其他的我就不知道了! --------------------编程问答-------------------- 这是数学问题
你要了解复数的-,*,/这些操作是怎样进行的
实部和虚部各是怎样处理的
然后仿照+的算法写不就完了吗
补充:.NET技术 , C#