-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGRF_Zerlegung.java
48 lines (32 loc) · 946 Bytes
/
GRF_Zerlegung.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
import java.util.ArrayList;
public class GRF_Zerlegung {
public static void main(String[] args) {
int index = 0;
ArrayList<String> liste = new ArrayList<String>();
String s1 = "-0,5x^2-22x-23x^3";
System.out.println("Funktionsgleichung: "+s1);
char[] tabelle = s1.toCharArray();
for (int i = 1; i < tabelle.length; i++) {
if ((tabelle[i] == '+') || (tabelle[i] == '-') ) {
liste.add(s1.substring(0, i));
break;
}
}
index = liste.get(0).length();
s1 = s1.substring(index);
tabelle = s1.toCharArray();
for (int j = 1; j < tabelle.length; j++) {
if (tabelle[j] == '-' || (tabelle[j] == '+') ) {
liste.add(s1.substring(0,j));
}
}
index = liste.get(1).length();
s1 = s1.substring(index);
tabelle = s1.toCharArray();
liste.add(s1);
System.out.println("Faktoren:");
for (int i = 0; i < 3; i++) {
System.out.println(liste.get(i));
}
}
}