重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
1. 代码如下,3)需要实际运行时输入测试
创新互联是一家专业提供永定企业网站建设,专注与成都做网站、成都网站制作、H5页面制作、小程序制作等业务。10年已为永定众多企业、政府机构等服务。创新互联专业网站设计公司优惠进行中。
int main(void)
{
double x, y, f;
printf("Please input 2 double number in the form of x y:\n");
scanf("%lf%lf", x, y);
if(x=0 y0)
f = 2*x*x + 3*x +1/(x+y);
else if(x=0 y=0)
f = 2*x*x + 3*x +1/(1+y*y);
else
f = 3*sin(x+y)/(2*x*x) + 3*x + 1;
printf("x=%lf, y=%lf, f(x, y)=%lf\n", x, y, f);
return 0;
}
2.代码如下
#include stdio.h
#includemath.h
int main(void)
{
double x, y, f;
printf("Please input 2 double number in the form of x y:\n");
scanf("%lf%lf", x, y);
if(x=0)
{
if(y0)
f = 2*x*x + 3*x +1/(x+y);
else
f = 2*x*x + 3*x +1/(1+y*y);
}
else
f = 3*sin(x+y)/(2*x*x) + 3*x + 1;
printf("x=%lf, y=%lf, f(x, y)=%lf\n", x, y, f);
return 0;
}
3.代码如下
#include stdio.h
int main(void)
{
int score = 0;
printf("Please input a score between 0-100:\n");
scanf("%d", score);
if(score0 || score100)
printf("Wrong input of score!\n");
else if(score=90 score=100)
printf("A\n");
else if(score=80 score=89)
printf("B\n");
else if(score=70 score=79)
printf("C\n");
else if(score=60 score=69)
printf("D\n");
else
printf("E\n");
return 0;
}
#includestdio.h
int main()
{
int x,y;
scanf("%d",x);
if(x-10)
y=0;
else if(x100) y=5*x+1;
else
y = 5*x + 1; //这个表达式的值是什么啊
printf("%d\n",y);
return 0;
}
简单写一下主函数
int x,y;
printf("x=");
scanf("%d",x);
if(x==0){
y=-1;
printf("y=%d",y);}
else if(x0){
y=x;
printf("y=%d",y);}
else if(x0x10){
y=x+1;
printf("y=%d",y);}
else{
printf("****不在范围内");}
return 0;
写法1
if (x-5 x0) y = x;
if (x == 0) y=x-1;
if (x0 x10) y = x+1;
写法2
if (x-5 x10)
{
y=x; //在这个范围,不论怎样,先把y赋值为x
if (x=0) //在这个范围,需要对y值做修改
{
y = y-1; //先把y-1再说,对应x=0的情况,如果x!=0,那么我们再次修改
if(x0)
y = y+2; //刚刚y-1了,所以需要+2
}
}
写法3,终于是正常点的做法了
if (x-5 x0) y=x;
else
{
if (x10)
{
if (x==0) y=x-1;
else y=x+1;
}
}
写法4
switch(x)
{
case 0:
y=x-1;
break;
case -4;
case -3;
case -2;
case -1;
y=x;
break;
case 1;
case 2;
case 3;
case 4;
case 5;
case 6;
case 7;
case 8;
case 9;
y=x+1;
break;
}
#include
int main()
{
int x,y;
scanf("%d",x);
if(0xx10) y=3*x+2;
else
{if(x=0) y=0;
else
{if (x0) y=x*x;
else printf("go die\n");
}
}
printf("%d",y);
return 0;
}该程序的分段函数如下:
f(x)=3x+2 (0x10)
f(x)=1 (x=0)
f(x) = x*x (x0)
#include stdio.h
#include math.h
void main()
{
float x;
double y;
printf("Please input the value of x:");
scanf("%f",x);
if(x=-10x=4)
{
y=fabs(x-2);
printf("y=%.2f\n",y);
}
else if(x=5x=7)
{
y=x+10;
printf("y=%.2f\n",y);
}
else if(x=8x=12)
{
y=pow(x,4);
printf("y=%.2f\n",y);
}
else
printf("No answer\n");
}
#include stdio.h
#include math.h
int main()
{
float x,y;
printf("please input x:");
scanf("%f",x);
if(x0 x!=-3)
y = pow(x,2)+x-6;
else if(x=0 x10 x!=2 x!=3)
y = pow(x,2)-5*x+6;
else
y = pow(x,2)-x-1;
printf("y=%f\n",y);
return 0;
}