[求助] pow 明白含义,但不明白格式是怎么写的
#include <stdio.h>#define PI 3.14159
int main()
{
printf("please input the tadius of the cone:\n");
scanf("%f",r);
printf("please input the beight of the cone:\n");
scanf("%f",h);
s=PI*r(r+pow(r*r+h*h,0.5)); /*这条我不明白是什么公式,能用数学公式写出来,好让明白啊,谢谢*/
v=PI*r*r*h;
printf("the area of the cone is %f\n",s);
printf("the volume of the cone is f",v);
return 0;
}
这里叫修改..但我定义float 也错误 . 这里我知首pow含义..但不懂用...
----------------解决方案--------------------------------------------------------
double pow(double x ,double y);
计算以x为底数的y次幂
定义double类型
----------------解决方案--------------------------------------------------------
我希望可以帮忙改错啊.这里面并不只有这一个错误啊? 谢谢了
----------------解决方案--------------------------------------------------------
有很多错啊!!
----------------解决方案--------------------------------------------------------
scanf("%f",&r);&表明取地址,
同类型的自己试着改改.
r什么的怎么可以都没有定义啊?
----------------解决方案--------------------------------------------------------
#include <stdio.h>
#define PI 3.14159
int main()
{
double r,h,s,v;
printf("please input the tadius of the cone:\n");
scanf("%lf",&r);
printf("please input the beight of the cone:\n");
scanf("%lf",&h);
s=PI*r*(r+pow(r*r+h*h,0.5)); /*这条我不明白是什么公式,能用数学公式写出来,好让明白啊,谢谢*/
v=PI*r*r*h;
printf("the area of the cone is %lf\n",s);
printf("the volume of the cone is %lf",v);
return 0;
}
----------------解决方案--------------------------------------------------------
#include <stdio.h>
#define PI 3.14159
int main()
{
float r;
float h;
float s;
float v;
double pow(double x,double y);
printf("please input the tadius of the cone:\n");
scanf("%f",&r);
printf("please input the beight of the cone:\n");
scanf("%f",&h);
s=PI*r(r+pow(r*r+h*h,0.5));
v=PI*r*r*h;
printf("the area of the cone is %f\n",s);
printf("the volume of the cone is f",v);
return 0;
}
我改成这样了.. 但还是出现两个错误 "调用未定义函数在main 中" 可能's'定义以前使用了它在main 函数中
求解啊............高手们..帮帮我吧
----------------解决方案--------------------------------------------------------
#include <stdio.h>
#include <math.h>
#define PI 3.14159
int main()
{
float r, h,s,v;
printf("please input the tadius of the cone:\n");
scanf("%f",&r);
printf("please input the beight of the cone:\n");
scanf("%f",&h);
s=PI*r(r+pow(r*r+h*h,0.5)); /*((r*r+h*h)的0.5次幂加上r,再乘以PI*r)*/
v=PI*r*r*h;
printf("the area of the cone is %f\n",s);
printf("the volume of the cone is %f",v);
return 0;
}
这样不知道可不可以了?!
----------------解决方案--------------------------------------------------------