#include<stdio.h>
int main(){
float x,y
scanf("%f",&x)
if(x==1){
y=2*x-1
}else{
y=1/(1-x*x)
}
printf("%f\n",y)
return 0
}
#include
int main()
{
int x,y
scanf("%d",&x)
if(0<x&&x<10) y=3*x+2
else
{if(x=0) y=0
else
{if (x<0) y=x*x
else printf("go die\n")
}
}
printf("%d",y)
return 0
}该程序的分段函数如下:
f(x)=3x+2 (0<x<10)
f(x)=1 (x=0)
f(x) = x*x (x<0)
#include <stdio.h>
#include <math.h>
void main()
{
float x
double y
printf("Please input the value of x:")
scanf("%f",&x)
if(x>=-10&&x<=4)
{
y=fabs(x-2)
printf("y=%.2f\n",y)
}
else if(x>=5&&x<=7)
{
y=x+10
printf("y=%.2f\n",y)
}
else if(x>=8&&x<=12)
{
y=pow(x,4)
printf("y=%.2f\n",y)
}
else
printf("No answer\n")
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)