maj
This commit is contained in:
73
DEV3.4/ControleMachine/test/ExempleSY5.java
Normal file
73
DEV3.4/ControleMachine/test/ExempleSY5.java
Normal file
@@ -0,0 +1,73 @@
|
||||
import java.util.Deque;
|
||||
import java.util.ArrayDeque;
|
||||
|
||||
public class ExempleSY5{
|
||||
public static void main(String[] args){
|
||||
// 3 + 4 * 2 / ( 1 − 5 ) ^ 2 ^ 3
|
||||
// doit donner 342*15-23^^/+
|
||||
Deque<AbstractToken> expression = new ArrayDeque<AbstractToken>();
|
||||
expression.addLast(new TokenConstant(3));
|
||||
expression.addLast(new TokenOperator(Operator.ADD));
|
||||
expression.addLast(new TokenConstant(4));
|
||||
expression.addLast(new TokenOperator(Operator.MUL));
|
||||
expression.addLast(new TokenConstant(2));
|
||||
expression.addLast(new TokenOperator(Operator.DIV));
|
||||
expression.addLast(new TokenSeparator(Separator.LB));
|
||||
expression.addLast(new TokenConstant(1));
|
||||
expression.addLast(new TokenOperator(Operator.SUB2));
|
||||
expression.addLast(new TokenConstant(5));
|
||||
expression.addLast(new TokenSeparator(Separator.RB));
|
||||
expression.addLast(new TokenOperator(Operator.EXP));
|
||||
expression.addLast(new TokenConstant(2));
|
||||
expression.addLast(new TokenOperator(Operator.EXP));
|
||||
expression.addLast(new TokenConstant(3));
|
||||
|
||||
ShuntingYard se = new ShuntingYard(expression);
|
||||
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user