📄 comtest.java
字号:
class complex{
int x,y;
complex(int a,int b){x=a;y=b;}
complex(){x=0;y=0;}
public void show()
{if (x<0 && y>0) System.out.println( " "+x+"+"+y+"i");
if (x<0 && y<0) System.out.println(" "+x+y+"i");
if (x>0 && y>0) System.out.println(x+"+"+y+"i");
if (x>0 && y<0) System.out.println(x+y+"i");
if (x==0 && y!=0) System.out.println(y+"i");
if ( x!=0 && y==0) System.out.println(x);
if (x==0 && y==0) System.out.println(0);}
public complex add(complex m,complex n )
{complex temp=new complex();
temp.x=m.x+n.x;
temp.y=m.y+n.y;
return temp;
}
public complex jian(complex m,complex n)
{complex temp=new complex();
temp.x=m.x-n.x;
temp.y=m.y-n.y;
return temp;}
}
class comtest{
public static void main(String args[]){
complex c1=new complex(5,5);
complex c2=new complex(10,4);
complex c3=new complex();
complex c4=new complex();
c3=c1.add(c1,c2);
c4=c1.jian(c1,c2);
c1.show();
c2.show();
c3.show();
c4.show();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -