新手渣渣制作——分割算式

494 查看

public class test01 {
public static void main(String[] args) {
String s1[]={"1","+","(","(","4","","5","-","2","3","3",")","+","6","6","6",")","+","5"};
String s2="";
int i2=1;
int i3=0;
int i4=0;
int i5=0;
String[] s3 = null;
String[] s4 = null;
boolean b1=false;
for(int i1=0;i1<s1.length;i1++){
if(s1[i1].equals("+")s1[i1].equals("-")s1[i1].equals("
")s1[i1].equals("/")){
i2++;
i3++;
}else if(s1[i1].equals("(")s1[i1].equals(")")){
i3++;
}
}
s3=new String[i2];
s4=new String[i3];
look1:
for(int i1=0;i1<s1.length;i1++){
if(s1[i1].equals("0")s1[i1].equals("1")s1[i1].equals("2")s1[i1].equals("3")s1[i1].equals("4")s1[i1].equals("5")s1[i1].equals("6")s1[i1].equals("7")s1[i1].equals("8")s1[i1].equals("9")s1[i1].equals("0")){
s2=s2+s1[i1];
}else if(s1[i1].equals("+")s1[i1].equals("-")s1[i1].equals("*")s1[i1].equals("/")){
s3[i4]=s2;
s4[i5]=s1[i1];
s2="";
i4++;
i5++;
}else if(s1[i1].equals("(")s1[i1].equals(")")){
s4[i5]=s1[i1];
i5++;
}else{
System.out.println("运行错误!");
b1=true;
break look1;
}
}
look2:
while(true){
if(b1){
b1=false;
break look2;
}
s3[i4]=s2;
s2="";
for(int i6=0;i6<s3.length;i6++){
System.out.println(s3[i6]);
}
for(int i7=0;i7<s4.length;i7++){
System.out.println(s4[i7]);
}
break look2;
}
}
}