java学习第44天2020/8/18
一.
import java.util.Scanner; public class complexa { double real,image; complexa() { real=0;image=0; } public void set(double m,double n) { real=m;image=n; } public void fan() { real=-real; image=-image; } public void add(complexa l) { System.out.println(real+l.real+"+"+(image+l.image)+"i"); } public static void main(String [] args) { complexa q=new complexa(); complexa w=new complexa(); Scanner input=new Scanner(System.in); double []s=new double[4]; for(int i=0;i<4;i++) { s[i]=input.nextDouble(); } q.set(s[0],s[1]); w.set(s[2],s[3]); q.add(w); w.fan(); q.add(w); } }
昨天问题解决
二.
三.例题