본문내용
import pkg.*; // package
import java.io.*;
public class infix_to_postfix
{
public static void main(String[] args)
{
// 키보드 입력을 받기 위한 준비작업.
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String s;
int result;
try {
// 인풋을 받아서 작업 시작.
System.out.print("Input? ");
s = in.readLine();
// 중위표기를 후위표기로 바꾸기 위한 작업.
InfixToPostfixConverter itop = new InfixToPostfixConverter();
s = itop.ConvertExpr(s);
System.out.println("Postfix : " + s);
// 후위표기를 계산해서 답을 내는 작업.
PostfixEvaluator pe = new PostfixEvaluator();
result = pe.EvaluateExpr(s);
System.out.println("Result : " + result);
}
catch (IOException e)
{
System.out.println("Exception: " + e.getMessage());
}
}
}
import java.io.*;
public class infix_to_postfix
{
public static void main(String[] args)
{
// 키보드 입력을 받기 위한 준비작업.
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String s;
int result;
try {
// 인풋을 받아서 작업 시작.
System.out.print("Input? ");
s = in.readLine();
// 중위표기를 후위표기로 바꾸기 위한 작업.
InfixToPostfixConverter itop = new InfixToPostfixConverter();
s = itop.ConvertExpr(s);
System.out.println("Postfix : " + s);
// 후위표기를 계산해서 답을 내는 작업.
PostfixEvaluator pe = new PostfixEvaluator();
result = pe.EvaluateExpr(s);
System.out.println("Result : " + result);
}
catch (IOException e)
{
System.out.println("Exception: " + e.getMessage());
}
}
}
소개글