不买也看看啊!!!!!求个算术运算的算法!!!! 记得好像是有一个符号堆栈,还有一个数字堆栈,具体的还要请教高手了. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你一个算24的程序:function get24(a, b, c, d: integer): integer;var i, j, k: integer; fh: array[1..4] of string;begin fh[1] := '+'; fh[2] := '-'; fh[3] := '*'; fh[4] := '/'; for i := 1 to 4 do for j := 1 to 4 do for k := 1 to 4 do begin // showmessage(floattostr(calval(k, calval(i, a,calval(j, b, c) ), d)-0.000001)); if round(calval(k, calval(i, a, calval(j, b, c)), d)) = 24 then //cal (a+(b+c))+d begin writeln(ff, '(' + inttostr(a) + fh[i] + '(' + inttostr(b) + fh[j] + inttostr(c) + '))' + fh[k] + inttostr(d) + '=24'); end; if round(calval(k, calval(j, calval(i, a, b), c), d)) = 24 then //cal ((a+b)+c)+d begin writeln(ff, '((' + inttostr(a) + fh[i] + inttostr(b) + ')' + fh[j] + inttostr(c) + ')' + fh[k] + inttostr(d) + '=24'); end; if round(calval(i, a, calval(j, b, calval(k, c, d)))) = 24 then //cal a+(b+(c+d)) begin writeln(ff, inttostr(a) + fh[i] + '(' + inttostr(b) + fh[j] + '(' + inttostr(c) + fh[k] + inttostr(d) + '))' + '=24'); end; if round(calval(i, a, calval(k, calval(j, b, c), d))) = 24 then //cal a+((b+c)+d) begin writeln(ff, inttostr(a) + fh[i] + '((' + inttostr(b) + fh[j] + inttostr(c) + ')' + fh[k] + inttostr(d) + ')' + '=24'); end; if round(calval(j, calval(i, a, b), calval(k, c, d))) = 24 then //cal (a+b)+(c+d)) begin writeln(ff, '(' + inttostr(a) + fh[i] + inttostr(b) + ')' + fh[j] + '(' + inttostr(c) + fh[k] + inttostr(d) + ')' + '=24'); end; end;end; 这个啊,找本数据结构的基础书籍看看~~~先转逆波兰式google搜索下~~~http://content.edu.tw/senior/computer/ks_ks/et/datastruct/compute/compute.htmhttp://tzsvc.xiloo.com/ks/datastru/dh3.htm找到了一个例子http://www.tommstudio.com/zips/tomm/calculator.rar TO:ehom(?!) THANK YOU@! 大哥,能不能帮小弟再解决一个问题,嘻嘻.http://expert.csdn.net/Expert/topic/1825/1825197.xml?temp=.2016565 一道几何题,如何证明,能否编程来证明? 如何获取opera中打开的页面中打开的网页的源代码 我用IdAntiFreeze来防止程序没有响应,为什么不行? 关于程序发布和更新问题 请教查找和注销动态生成的控件。 我有D7设计ActiveX组件,为什么只能编译一次? 用DELPHI如何控制鼠标在路径上运动,并能自动执行双击。 这个打印判断的问题怎么就是不能解决 sql server 2008 卸载后电脑速度仍然慢 如何在DELPHI中访问其它计算机上的MYSQL的数据库啊?求助啊!!! 急!急!急!有关提取磁盘序列号的问题!在线等待! 如何让一个DATASET的纪录排序?
function get24(a, b, c, d: integer): integer;
var
i, j, k: integer;
fh: array[1..4] of string;
begin
fh[1] := '+';
fh[2] := '-';
fh[3] := '*';
fh[4] := '/'; for i := 1 to 4 do
for j := 1 to 4 do
for k := 1 to 4 do
begin
// showmessage(floattostr(calval(k, calval(i, a,calval(j, b, c) ), d)-0.000001));
if round(calval(k, calval(i, a, calval(j, b, c)), d)) = 24 then //cal (a+(b+c))+d
begin
writeln(ff, '(' + inttostr(a) + fh[i] + '(' + inttostr(b) + fh[j] + inttostr(c) + '))' + fh[k] + inttostr(d) + '=24');
end;
if round(calval(k, calval(j, calval(i, a, b), c), d)) = 24 then //cal ((a+b)+c)+d
begin
writeln(ff, '((' + inttostr(a) + fh[i] + inttostr(b) + ')' + fh[j] + inttostr(c) + ')' + fh[k] + inttostr(d) + '=24');
end;
if round(calval(i, a, calval(j, b, calval(k, c, d)))) = 24 then //cal a+(b+(c+d))
begin
writeln(ff, inttostr(a) + fh[i] + '(' + inttostr(b) + fh[j] + '(' + inttostr(c) + fh[k] + inttostr(d) + '))' + '=24');
end;
if round(calval(i, a, calval(k, calval(j, b, c), d))) = 24 then //cal a+((b+c)+d)
begin
writeln(ff, inttostr(a) + fh[i] + '((' + inttostr(b) + fh[j] + inttostr(c) + ')' + fh[k] + inttostr(d) + ')' + '=24');
end;
if round(calval(j, calval(i, a, b), calval(k, c, d))) = 24 then //cal (a+b)+(c+d))
begin
writeln(ff, '(' + inttostr(a) + fh[i] + inttostr(b) + ')' + fh[j] + '(' + inttostr(c) + fh[k] + inttostr(d) + ')' + '=24');
end;
end;
end;
http://tzsvc.xiloo.com/ks/datastru/dh3.htm找到了一个例子
http://www.tommstudio.com/zips/tomm/calculator.rar
THANK YOU@!
大哥,能不能帮小弟再解决一个问题,嘻嘻.
http://expert.csdn.net/Expert/topic/1825/1825197.xml?temp=.2016565