#include <stdio.h>
#include <math.h>
int main()
{
double x,y;
printf("Enter x:\n");
scanf("%lf",&x) ;
if(x<0)
{
y=pow(x+1,2)+2*x+pow(x,-1);
}
else if(x>=0)
{
y=sqrt(x);
}
printf("%.2f",y);
return 0;
}
诶嘿嘿今天第二次发布,今天终于搞明白%f和%lf的用法了
具体如下;分为输入(scanf)和输出(printf)
输入时float用%f,double用%lf(一定一定一定!!!)
输出时float和double用%f和%lf都可以