重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
#include "stdio.h"
网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、小程序定制开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了炎陵免费建站欢迎大家使用!
#includemath.h
void main()
{
double x,y,f,h;
printf("请输入x:\n");
scanf("%lf",x);
printf("请输入y:\n");
scanf("%lf",y);
if((x=0)(y0))
f=2*pow(x,2)+3*x+1/x+y;
else if((x=0)(y=0))
f=2*x*x+3*x+1/x+y*y;
else
f=3*sin(x+y)/2/pow(x,2)+3*x+1;
printf("x=%lf,y=%lf,f=%lf\n",x,y,f);
h=pow(x,2);
printf("%lf",h);
}
写法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;
}
int sign(int x)
{
int y;
scanf("%d",x);
if(x0)
y=1;
else if(x==0)//判断语句是==不是=号
y=0;
else
y=-1;
return y;
}
1. 代码如下,3)需要实际运行时输入测试
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;
}