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)
如果输入x值不再取值范围内,打印go die...
学好编程最重要的是自己要思考,要想。不然没有任何进步。
x=val(inputbox("乱敏陵请你输入拿老X的值"哗戚)if x<0 then
y=1-2*x
else
y=1+x
end if
print y
1,#include<Stdio.h>int main(){
int x = 0
scanf("%d",&x)
if(x <0)
printf("-1")
else if( x == 0)
printf("0")
else
printf("1")
return 0
}
2,#include<stdio.h>
int main(){
float a,b,c
scanf("%f%f%f",&a,&b,&c)
if(a >b)
a = a+b - (b = a)
if(c <a){
c = a + c -( a = c)
c = b + c - (b = c)
}
if(c <b)
c = c+b - (b = c)
printf("%f %f %f",c,b,a)
return 0
}
3,#include<stdio.h>
int main(){
int a ,b,c
scanf("%d%d%d",&a,&b,&c)
printf("%d",(a>b?a:b)>c?(a>b?a:b):c)
return 0
}
4,#include<stdio.h>嫌樱
int main(){
float r = 0
printf("请输入半径"指者和唯盯)
scanf("%f",&r)
printf("周长是%f",2*3.14*r)
printf("面积是%f",3.14*r*r)
return 0
}
5,#include<stdio.h>
#include<math.h>
int main(){
int x = 0
scanf("%d",&x)
if (x <-10)
printf("%d",5- x)
else if( x <= 10)
printf("%d", 4 * x -8)
else
printf("%d",sqrt(x))
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)