?? 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 + -