consistenta.java
来自「A simple chaine list example in java Wa」· Java 代码 · 共 54 行
JAVA
54 行
public class Consistenta {
public static boolean deschis(char x){
if (x=='[' || x=='{' || x=='(')
return true;
return false;
}
public static boolean inchis(char x){
if (x==']' || x=='}' || x==')')
return true;
return false;
}
public static boolean compare(char x,char y){
if (x=='[' && y==']') {
return true;
} else if (x=='{' && y=='}') {
return true;
} else if (x=='(' && y==')') {
return true;
}
return false;
}
public static void main(String[] args) {
Stiva a=new Stiva();
char [] str=args[0].toCharArray();
boolean g=true;
for (int i=0;i<str.length;i++){
if (deschis(str[i])) {
a.Baga(str[i]);
} else if (inchis(str[i])) {
char t=a.Scoate();
if (!compare(t,str[i])) {
g=false;
}
}
}
if (!a.Gol()) g=false;
if (g) {
System.out.print("E regulara expresia");
} else {
System.out.print("Nu e regulara expresia");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?