網頁

2011年11月24日 星期四

將後序算式計算答案

將後序算式計算答案
18,6,/,3,2,*,-

61 則留言:

  1. /,+,15,6,3
    =>/,21,3
    =7;

    回覆刪除
  2. import java.util.*;
    public class A1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }

    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }

    }

    回覆刪除
  3. import java.util.*;
    public class b1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }

    }

    回覆刪除
  4. import java.util.*;
    public class Postfix2A {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  5. import java.util.*;
    public class Postfix2A {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  6. import java.util.*;
    public class Postfix2A {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  7. import java.util.*;
    public class Postfix2A {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  8. import java.util.*;
    public class Postfix2A {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  9. import java.util.*;
    public class Postfix2A {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  10. package pack1;
    import java.util.*;
    public class a2 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  11. import java.util.*;
    public class B1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {

    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  12. import java.util.*;
    public class A1{
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  13. package pack1;
    import java.util.*;
    public class A1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }


    }

    回覆刪除
  14. package b1;
    import java.util.*;
    public class b1 {

    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  15. import java.util.*;
    public class Postfix2A {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList number= new LinkedList();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  16. package b1;
    import java.util.*;
    public class b1 {

    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  17. import java.util.*;
    public class Postfix2A {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  18. import java.util.*;
    public class B9933051
    {
    static boolean isOperator(String op)
    {
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }

    static int compute(int A, int B, String op)
    {
    if (op=="+")
    return A+B;
    else if (op=="-")
    return A-B;
    else if (op=="*")
    return A*B;
    else if (op=="/")
    return A/B;
    else
    {
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }

    public static void main(String[] args)
    {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();

    for(int i=0; i<f.length; i++)
    {
    if(!isOperator(f[i]))
    {
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else
    {
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  19. import java.util.*;
    public class Postfix2A {

    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }


    }

    回覆刪除
  20. package P1;
    import java.util.*;
    public class A1
    {
    static boolean isOperator(String op)
    {
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op)
    {
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else
    {
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args)
    {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++)
    {
    if(!isOperator(f[i]))
    {
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else
    {
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());

    }

    }

    回覆刪除
  21. package pack1;
    import java.util.*;
    public class t1 {



    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  22. import java.util.*;
    public class Postfix2A {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  23. package Postfix2A;
    import java.util.*;
    public class Postfix2A {

    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  24. package A1;
    import java.util.*;
    public class B1
    {
    static boolean isOperator(String op)
    {
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op)
    {
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else
    {
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args)
    {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++)
    {
    if(!isOperator(f[i]))
    {
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else
    {
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());

    }

    }

    回覆刪除
  25. package pack;
    import java.util.*;
    public class pack {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }

    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  26. package pack;
    import java.util.*;
    public class pack {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }

    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  27. import java.util.*;
    public class Postfix2A {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  28. import java.util.*;
    public class b1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A,int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int p=1;
    for(int i=1; i<=B;i++)
    p*=A;
    return p;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    //答案:-3;

    回覆刪除
  29. package p1;
    import java.util.*;
    public class b1 {

    /**
    * @param args
    */
    // TODO Auto-generated method stub
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }

    }

    回覆刪除
  30. package b1;
    import java.util.*;
    public class Postfix2A {

    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  31. import java.util.*;
    public class B1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {

    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }
    ..

    回覆刪除
  32. package p1;
    import java.util.*;
    public class b1 {

    /**
    * @param args
    */

    // TODO Auto-generated method stub


    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }

    }

    回覆刪除
  33. import java.util.*;
    public class Postfix2A {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList number= new LinkedList();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  34. public class tt
    {
    static boolean isOperator(String op)
    {
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op)
    {
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else
    {
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args)
    {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++)
    {
    if(!isOperator(f[i]))
    {
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else
    {
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  35. package V1;
    import java.util.*;
    public class B9933052A{
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }
    答案=-3

    回覆刪除
  36. import java.util.*;
    public class B1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {

    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }
    ..

    回覆刪除
  37. import java.util.*;
    public class B1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {

    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }
    ..

    回覆刪除
  38. import java.util.*;
    public class B1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {

    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }
    ..

    回覆刪除
  39. import java.util.*;
    public class A1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  40. package pack1;
    import java.util.*;
    public class t1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {

    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }



    }

    回覆刪除
  41. import java.util.*;
    public class A1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  42. import java.util.*;
    public class A1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  43. import java.util.*;
    public class A1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  44. import java.util.*;
    public class A1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  45. package dddfff;

    import java.util.*;
    public class aaasss {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  46. import java.util.*;
    public class A1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  47. import java.util.*;
    public class b9933011 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  48. package p1;
    import java.util.*;
    public class V1 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A,int B,String op)
    {
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1;i<=B;i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number=new LinkedList<Integer>();
    for(int i=0;i<f.length;i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());

    }

    }

    回覆刪除
  49. import java.util.*;
    public class B1 {

    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }

    }

    回覆刪除
  50. package P1;
    import java.util.*;
    public class A1
    {
    static boolean isOperator(String op)
    {
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op)
    {
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else
    {
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args)
    {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++)
    {
    if(!isOperator(f[i]))
    {
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else
    {
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());

    }

    }

    回覆刪除
  51. package P1;
    import java.util.*;
    public class A1
    {
    static boolean isOperator(String op)
    {
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op)
    {
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else
    {
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args)
    {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++)
    {
    if(!isOperator(f[i]))
    {
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else
    {
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());

    }

    }

    回覆刪除
  52. package P1;
    import java.util.*;
    public class A1
    {
    static boolean isOperator(String op)
    {
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op)
    {
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else
    {
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args)
    {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++)
    {
    if(!isOperator(f[i]))
    {
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else
    {
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());

    }

    }

    回覆刪除
  53. package P1;
    import java.util.*;
    public class A1
    {
    static boolean isOperator(String op)
    {
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op)
    {
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else
    {
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args)
    {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++)
    {
    if(!isOperator(f[i]))
    {
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else
    {
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());

    }

    }

    回覆刪除
  54. package P1;
    import java.util.*;
    public class A1
    {
    static boolean isOperator(String op)
    {
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op)
    {
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else
    {
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args)
    {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++)
    {
    if(!isOperator(f[i]))
    {
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else
    {
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());

    }

    }

    回覆刪除
  55. import java.util.*;
    public class b9733054 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  56. import java.util.*;
    public class B9933007 {
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList number= new LinkedList();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  57. package P1;
    import java.util.*;
    public class A1
    {
    static boolean isOperator(String op)
    {
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op)
    {
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else
    {
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args)
    {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++)
    {
    if(!isOperator(f[i]))
    {
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else
    {
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());

    }

    }

    回覆刪除
  58. package P1;
    import java.util.*;
    public class A1
    {
    static boolean isOperator(String op)
    {
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op)
    {
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else
    {
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args)
    {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();
    for(int i=0; i<f.length; i++)
    {
    if(!isOperator(f[i]))
    {
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else
    {
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());

    }

    }

    回覆刪除
  59. import java.util.*;
    public class Postfix2A
    {
    static boolean isOperator(String op)
    {
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }

    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }

    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();

    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i]))
    {
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }

    else
    {
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }

    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  60. import java.util.*;
    public class A1{
    static boolean isOperator(String op){
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }
    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }
    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList number= new LinkedList();
    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i])){
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }
    else{
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }
    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除
  61. import java.util.*;
    public class Postfix2A
    {
    static boolean isOperator(String op)
    {
    if (op=="+"||op=="-"||op=="*"||op=="/"||op=="^")
    return true;
    else
    return false;
    }

    static int compute(int A, int B, String op){
    if (op=="+") return A+B;
    else if (op=="-") return A-B;
    else if (op=="*") return A*B;
    else if (op=="/") return A/B;
    else{
    int P=1;
    for(int i=1; i<=B; i++)
    P*=A;
    return P;
    }
    }

    public static void main(String[] args) {
    String f[]={"18","6","/","3","2","*","-"};
    LinkedList<Integer> number= new LinkedList<Integer>();

    for(int i=0; i<f.length; i++){
    if(!isOperator(f[i]))
    {
    int n=Integer.parseInt(f[i]);
    number.push(n);
    }

    else
    {
    int B=number.pop();
    int A=number.pop();
    int C=compute(A,B,f[i]);
    number.push(C);
    }

    System.out.println(number);
    }
    System.out.println("答案="+number.pop());
    }
    }

    回覆刪除

HTML 編輯器