在delphi中,经常会遇到x的y次方的情况,那么首先在interface下面的uses栏加上math。
然后在程序中如下书写:
power(x,y);表示x的y次方。如果y<1,例如y=1/4,这就是对x开四次方。
附一简单小程序,将edit1和edit2中的数字转换,然后求解-1的edit1+edit2次方
x:=strtofloat(edit1.Text);
y:=strtofloat(edit2.Text);
label1.Caption:=floatToStr(power(-1,x+y));
本文标题: | [Delphi] delphi中x的y次方 |
本文链接: (转载请附上本文链接) | https://vulsee.com/archives/vulsee_2008/0922_571.html |