using system;
class twentyfourpoint
;private char symbolsortcard = new char[448];
private char tempsymbolsortcard = new char[3];
private expressionvalue expressionvalue = new expressionvalue();
public void setcard(char card)
public void sortcard()}}
}}}}
}private void addsymbol()}}
}public void addnumtosymbol()
for(int i = 0; i < 64; i++)}}
private void clearexpression(char expression)
private char ***pactspace(char a)
return b;
}private void printexpression(char a)
console.write("/n");}}
public class charstack
else
}public char pop()
else
}public char checktop()}}
public class intstack
else
console.writeline("the intstack is full");
}public int pop()
else
}public int checktop()}}
public class expressionvalue
public int value()
else if(letter == '#' && opr.checktop() == '#')
break;
else if(letter == '(')
else if(letter ==')')
else
}else if(priority(letter) > priority(opr.checktop()))
else if(priority(letter) <= priority(opr.checktop()))
}opr.pop();
return opd.pop();
}private int priority(char c)
return p;
}private int operate(int opda, char oprc, int opdb)}}
public class run
a.setcard(card);
a.addnumtosymbol();
console.writeline("如想退出本程式,請輸入字母e,否則按任意鍵繼續......");
input = console.readline();
}while(input.toupper() != "e"); } }
計算24點的簡單程式
近來家庭作業裡有24點的題目,為了找出所有可能的組合,就寫了個簡單的程式 1.執行程式 2.輸入4個整數,比如 3 3 7 8 3.顯示所有可能的組合 include assert.h include double operate double num1,double num2,int op els...
乙個樸素的24點演算法
include include include include define oper add 0x00000001 define oper sub 0x00000002 define oper mul 0x00000004 define oper div 0x00000008 define opt...
C 計算24點的簡單程式
近來家庭作業裡有24點的題目,為了找出所有可能的組合,就寫了個簡單的程式 1.執行程式 2.輸入4個整數,比如 3 3 7 8 3.顯示所有可能的組合 include assert.h include double operate double num1,double num2,int op els...