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); }
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); }
/,+,15,6,3
回覆刪除=>/,21,3
=7;
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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;
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());
}
}
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());
}
}
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());
}
}
..
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());
}
}
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());
}
}
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());
}
}
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
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());
}
}
..
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());
}
}
..
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());
}
}
..
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}