/******************
原题:有一分段函数,y=f(x).当x小于6时,y= x - 12;
当x大于6且小于15时,y = 3x - 1;
当x大于等于15时,y = 5x + 9;
*******************/
#include <stdio.h>
int main(int argc, char *argv[])
{
int x, y;
printf("请输入自变量: ");
scanf("%d",&x);
if(x < 6)
{
y = x -12;
printf("x = %d, y = %d\n",x ,y);
}
else if(x < 15)
{
y = 3*x - 1;
printf("x = %d, y = %d\n",x ,y);
}
else
{
y = 5*x +9;
printf("x = %d, y = %d\n",x ,y);
}
while(1);
return 0;
}
|