|
发表于 2022-11-16 22:32:59
From FishC Mobile
|
显示全部楼层
|阅读模式
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
#include <math.h>
//double power(double x,double y);
void main()
{
double power(double x,double y);
double a,b,c;
printf("input two numbers: ");
scanf("%.2f,%.2f",&a,&b);
c=power(a,b);
printf("%.2f 的%.2f是%.2f\n",a,b,c);
}
double power(double x,double y)
{
double z;
for(z=1;y>=1;--y)
{
z=z*x;
return z;
}
}
实现pow函数有错误但是我看不出来求大佬解决一下
- #include <stdio.h>
- #include <math.h>
- extern double power(double x,double y);
- int main()
- {
- double a,c;
- int b;
- printf("input two numbers: ");
- scanf("%lf%d",&a,&b);
- c=power(a,b);
- printf("%lf 的%d是%.2f\n",a,b,c);
- return 0;
- }
- double power(double x,double y)
- {
- double z;
- for(z=1;y>=1;--y)
- {
- z=z*x;
-
- }
- return z;
-
-
- }[code]运行结果:
- input two numbers: 10 2
- 10.000000 的2是100.000000
- --------------------------------
- Process exited after 3.355 seconds with return value 0
- Press ANY key to exit...
复制代码[/code]
|
|