-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathComplexUse.java
54 lines (51 loc) · 1.11 KB
/
ComplexUse.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.util.Scanner;
public class ComplexUse {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int degree1[] = new int[n];
for(int i = 0; i < n; i++){
degree1[i] = s.nextInt();
}
int coeff1[] = new int[n];
for(int i = 0; i < n; i++){
coeff1[i] = s.nextInt();
}
Polynomial first = new Polynomial();
for(int i = 0; i < n; i++){
first.setCoefficient(degree1[i],coeff1[i]);
}
n = s.nextInt();
int degree2[] = new int[n];
for(int i = 0; i < n; i++){
degree2[i] = s.nextInt();
}
int coeff2[] = new int[n];
for(int i = 0; i < n; i++){
coeff2[i] = s.nextInt();
}
Polynomial second = new Polynomial();
for(int i = 0; i < n; i++){
second.setCoefficient(degree2[i],coeff2[i]);
}
int choice = s.nextInt();
Polynomial result;
switch(choice){
// Add
case 1:
result = first.add(second);
result.print();
break;
// Subtract
case 2 :
result = first.subtract(second);
result.print();
break;
// // Multiply
// case 3 :
// result = first.multiply(second);
// result.print();
// break;
}
}
}