如题所述
#include<stdio.h>
#include<math.h>
int main(void)
{
double x;
printf(" 请输入实数 x 的值:");
while(scanf("%lf",&x) == 1)
{
if(x<1.0)
printf(" y = 2 * %.2f + 3 = %-8.3f\n",x,2*x+3);
if(x>=1.0 && x<10)
printf(" y = 2 * %.2f^2 - 1 = %-8.3f\n",x,2*x*x-1);
if(x>=10)
printf(" y = √(3 * %.2f - 4) = %-8.3f\n",x,sqrt(3*x-4));
printf("\n 请输入实数 x 的值:");
}
return 0;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答 2018-04-27
#include <stdio.h>
#include <math.h>
int main ( )
{
double x,y;
printf("input x:");
scanf("%lf",&x);
if (x<1) y = 2*x+3;
else if (x>=10) y= sqrt( 3*x-4);
else y=2*x*x-1;
printf("y=%8.3f\n",y);
return 0;
}
#include <math.h>
int main ( )
{
double x,y;
printf("input x:");
scanf("%lf",&x);
if (x<1) y = 2*x+3;
else if (x>=10) y= sqrt( 3*x-4);
else y=2*x*x-1;
printf("y=%8.3f\n",y);
return 0;
}