herrDeng網內搜尋

自訂搜尋

Ads

2011年11月24日 星期四

將後序算式計算答案

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

61 則留言:

B9933042 提到...

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

B9933015 提到...

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());
}

}

B9933014 提到...

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());
}

}

B9933053 提到...

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());
}
}

b9733114 提到...

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());
}
}

B9733088 提到...

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());
}
}

b9733114 提到...

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());
}
}

B9933019 提到...

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());
}
}

B9933021 提到...

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());
}
}

B9933050 提到...

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());
}
}

B9933020 提到...

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());
}
}

B9933043 提到...

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());
}
}

B9933010 提到...

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());
}


}

B9933008 提到...

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());
}
}

B9933028 提到...

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());
}
}

B9933008 提到...

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());
}
}

b9933016 提到...

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());
}
}

B9933051 提到...

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());
}
}

B9933002 提到...

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());
}


}

B9933049 提到...

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());

}

}

B9933025 提到...

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());
}
}

B9933013 提到...

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());
}
}

B9933001 提到...

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());
}
}

B9933056 提到...

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());

}

}

B9933003 提到...

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());
}
}

B9933003 提到...

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());
}
}

B9733099黃彥翔 提到...

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());
}
}

B9933042 提到...

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;

B9933012 提到...

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());
}

}

B9933017 提到...

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());
}
}

b9933009 提到...

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());
}
}
..

B9733089 提到...

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());
}

}

b9733115 提到...

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());
}
}

B9933045 提到...

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());
}
}

B9933052 提到...

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

b9933018 提到...

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());
}
}
..

b9933033 提到...

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());
}
}
..

b9933034 提到...

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());
}
}
..

B9933040 提到...

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());
}
}

b9933047 提到...

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());
}



}

B9933004 提到...

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());
}
}

B9933046 提到...

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());
}
}

B9933039 提到...

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());
}
}

B9933057 提到...

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());
}
}

B9933044 提到...

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());
}
}

B9933043 提到...

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());
}
}

b9933011 提到...

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());
}
}

B9933038 提到...

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());

}

}

B9933041 提到...

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());
}

}

b9933005豐智偉 提到...

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());

}

}

b9933005豐智偉 提到...

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());

}

}

B9933036 提到...

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());

}

}

b9933024 提到...

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());

}

}

b9933055 提到...

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());

}

}

b9733054 提到...

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());
}
}

b9933007 提到...

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());
}
}

B9933023 提到...

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());

}

}

B9933023 提到...

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());

}

}

B9933006 提到...

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());
}
}

Z1001012 提到...

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());
}
}

b10033028 提到...

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());
}
}

Related Posts Plugin for WordPress, Blogger...

熱門文章