#include<stdio.h>
int main(void)
{
int i,n;
double x,y;
double fee(double x);
printf("Enter n:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter x:");
scanf("%Lf",&x);
if(x<=0)
printf("sorry you enter is wrony\n");
else{
y=fee(x);
}
printf("y=%.3f\n",y);
}
return 0;
}
double fee(double x)
{
double y;
if(x<=50)
{
y=0.53*x;
}
else
{
y=26.5+0.58*(x-50);
}
return y;
}
#include<stdio.h>
int main()
{
int i,n;
double r,v,h;
double cylinder(double r,double h);
printf("enter n:");
scanf("%d",&n);
for(i=1;i<=n;i++){
printf("Enter r and h:\n");
scanf("%lf%lf",&r,&h);
if((r<=0)||(h<=0))
{
printf("sorry you enter is wrony!\n");
}
else{
v=cylinder(r,h);
printf("V=%.3f\n",v);
}
}
return 0;
}
double cylinder(double r,double h)
{
double result;
result=3.1415926*r*r*h;
return result;
}
#include<stdio.h>
int main()
{
int n,i;
double x,y;
printf("Enter n:");
scanf("%d",&n);
for(i=1;i<=n;i++){
printf("Enter x:");
scanf("%lf",&x);
if(x<=0)
printf("sorry you enter is wrony\n");
else if(x<=50){
y=0.53*x;
}
else{
y=26.5+0.58*(x-50);
}
printf("y=%.3f\n",y);
}
return 0;
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步