import java.util.*; public class Main{ public static class Complex { public int real; public int image; public Complex(int real,int image){ this.real = real; this.image = image; } public static Complex mul(Complex c1,Complex c2){ int newReal = c1.real * c2.real - c1.image * c2.image; int newImage = c1.real * c2.image + c1.image * c2.real; return new Complex(newReal, newImage); } public static Complex add(Complex c1, Complex c2){ return new Complex(c1.real+c2.real,c1.image+c2.image); } public void show(){ System.out.println(real); System.out.println(image); } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); Complex[] a = new Complex[5]; Complex[] b = new Complex[5]; for(int i=0;i<5;i++){ a[i] = new Complex(sc.nextInt(),sc.nextInt()); } for(int i=0;i<5;i++){ b[i] = new Complex(sc.nextInt(),sc.nextInt()); } for(int i = 8; i >=0; i--){ getOne(i, a, b).show(); } } public static Complex getOne(int index, Complex[] a, Complex[] b){ Complex res = new Complex(0,0); for(int k = 0;k <=index ;k++){ Complex aa = (k>=0 && k<=4) ? a[k] : new Complex(0,0); Complex bb = (index-k>=0 && index-k<=4) ? b[index-k] : new Complex(0,0); res = Complex.add(res, Complex.mul(aa, bb)); } return res; } }
点赞 评论

相关推荐

点赞 评论 收藏
分享
11-24 11:23
门头沟学院 C++
点赞 评论 收藏
分享
牛客网
牛客企业服务