网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
09月05日漏签0天
prolog吧 关注:814贴子:2,620
  • 看贴

  • 图片

  • 吧主推荐

  • 游戏

  • 0回复贴,共1页
<<返回prolog吧
>0< 加载中...

计算器的代码

  • 只看楼主
  • 收藏

  • 回复
  • somaniya
  • ylsdd
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
window_brush(_, rgb(0,0,255)),
edit( G_S1, 1, fail(_), "", 10, 10,200, 25),
edit( G_S2, 1, fail(_), "", 10, 45,200, 25),
button(_,_,b7_func(_),"7",10,80,35,35),
button(_,_,b8_func(_),"8",50,80,35,35),
button(_,_,b9_func(_),"9",90,80,35,35),
button(_,_,b4_func(_),"4",10,120,35,35),
button(_,_,b5_func(_),"5",50,120,35,35),
button(_,_,b6_func(_),"6",90,120,35,35),
button(_,_,b1_func(_),"1",10,160,35,35),
button(_,_,b2_func(_),"2",50,160,35,35),
button(_,_,b3_func(_),"3",90,160,35,35),
button(_,_,b0_func(_),"0",10,200,35,35),
button(_,_,point_func(_),".",50,200,35,35),
button(_,_,back_func(_),"<-",90,200,35,35),
button(_,_,plus_func(_),"+",140,160,35,75),
button(_,_,ravno_func(_),"=",180,200,35,35),
button(_,_,mult_func(_),"*",180,160,35,35),
button(_,_,minus_func(_),"-",140,120,35,35),
button(_,_,div_func(_),"/",180,120,35,35),
button(_,_,onc_func(_),"on/c",140,80,75,35),
button(_,_,lskoba_func(_),"(",220,200,35,35),
button(_,_,dskoba_func(_),")",260,200,35,35),
button(_,_,sin_func(_),"sin",220,80,35,35),
button(_,_,cos_func(_),"cos",220,120,35,35),
button(_,_,tg_func(_),"tg",220,160,35,35),
button(_,_,arcsin_func(_),"arcs",260,80,35,35),
button(_,_,arccos_func(_),"arcc",260,120,35,35),
button(_,_,arctg_func(_),"arct",260,160,35,35),
button(_,_,sqr_func(_),"sqr",300,80,35,35),
button(_,_,exp_func(_),"exp",300,120,35,35),
button(_,_,nlog_func(_),"nlog",300,160,35,35),
button(_,_,dlog_func(_),"dlog",300,200,35,35),
button(_,_,b_func(_),"b",260,45,35,30),
button(_,_,x_func(_),"x",300,10,35,30),
button(_,_,pow_func(_),"pow",300,45,35,30),
button(_,_,a_func(_),"a",220,45,35,30),
button(_,_,dx_func(_),"dx",220,10,75,30).

% this clause is corrected by LEE, Chung-Woo
% from Korean Republic
menu_extend(press) :-
  size(_,X, _),
  X > 360, !.
menu_extend(press) :-
  repeat,
  size(_,X, Y),
  X1 is X + 1,
  size(_,X1, Y),  
  X1>360.

menu_normal(press) :-
  size(_,232,300).
  
b0_func(press) :- add_text(G_S1, "0").
b1_func(press) :- add_text(G_S1, "1").
b2_func(press) :- add_text(G_S1, "2").
b3_func(press) :- add_text(G_S1, "3").
b4_func(press) :- add_text(G_S1, "4").
b5_func(press) :- add_text(G_S1, "5").
b6_func(press) :- add_text(G_S1, "6").
b7_func(press) :- add_text(G_S1, "7").
b8_func(press) :- add_text(G_S1, "8").
b9_func(press) :- add_text(G_S1, "9").
plus_func(press) :-add_text(G_S1, "+").
minus_func(press) :-add_text(G_S1, "- ").
mult_func(press) :-add_text(G_S1, "*").
div_func(press) :-add_text(G_S1, "/").
point_func(press) :-add_text(G_S1, ".").
lskoba_func(press) :-add_text(G_S1, " (").
dskoba_func(press) :-add_text(G_S1, ")").
sin_func(press) :-add_text(G_S1, "sin(").
arcsin_func(press) :-add_text(G_S1, "arcsin(").
cos_func(press) :-add_text(G_S1, "cos(").
arccos_func(press) :-add_text(G_S1, "arccos(").
tg_func(press) :-add_text(G_S1, "tg(").
arctg_func(press) :-add_text(G_S1, "arctg(").
sqr_func(press) :-add_text(G_S1, "sqrt(").
exp_func(press) :-add_text(G_S1, "exp(").
nlog_func(press) :-add_text(G_S1, "log(").
dlog_func(press) :-add_text(G_S1, "log10(").
a_func(press) :-add_text(G_S1, "a").
b_func(press) :-add_text(G_S1, "b").
x_func(press) :-add_text(G_S1, "x").
pow_func(press) :-add_text(G_S1, "**").                      

ravno_func(press):-
  T is scan(get_text(G_S1)),
  Result is T,
  set_text(print(Result),G_S2).

onc_func(press) :- 
  set_text("",G_S1),
  set_text("",G_S2).

back_func(press) :-
  S is get_text(G_S1),
  L is str_length(S),
  sub_string(S2, S, 0, L- 1),
  set_text(S2,G_S1).

dx_func(press) :-
  T is scan(get_text(G_S1)),
  d( T, x, Result),
  simplify(Result,Result2),
  set_text(printq(Result2),G_S2).

% For dx

atomic(X) :-  not(X=..P).
d(X,X,1) :- !.
d(C,_,0) :- atomic(C).
%d(~U,X,~A) :- d(U,X,A).
d(U+V,X,A+B) :- d(U,X,A),d(V,X,B).
d(U-V,X,A-B) :- d(U,X,A),d(V,X,B).
d(C*U,X,C*A) :- atomic(C), C\=X,d(U,X,A),!.
d(U*V,X,B*U+A*V) :- d(U,X,A), d(V,X,B).
%d(U/V,X,A) :- d( V^V(~1), X, P).

simplify(E,F) :-
E = Op(L, R),
simplify(L,X),
simplify(R,Y),
s(Op,X,Y,F).
simplify(E,E).

s('+',X,Y,Z) :- number(X),number(Y), Z is X+Y.
s('+',X,0,X).
s('+',0,X,X).
s('+',X,X,R):-simplify(2*X,R).
s('+',X*Z,Y*Z,R*Z) :-number(X),number(Y), R is X+Y.
s('+',X,Y,Y+X) :- number(X).
s('+',X+Y,Z,X+W) :-number(Y),number(Z),W is Y+Z.
s('+',X+Y,Z,X+Z+Y) :- number(Y). 
s('+',X,Y,X+Y).
s('*',X,Y,Z) :- number(X),number(Y), Z is X*Y.
s('*',_,0,0).
s('*',0,_,0).
s('*',1,X,X).
s('*',X,1,X).
s('*',X,Y,Y*X) :- number(Y).
s('*',X*Y,W,Z*Y) :-number(X),number(W),Z is X*W.
s('*',X,Y*Z,R*Z) :- number(X),number(Y), R is X*Y. 
s('*',X,Y*Z,Y*X*Z) :- number(Y). 
s('*',X,Y,X*Y).



登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 0回复贴,共1页
<<返回prolog吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示