c程序设计第四版谭浩强
有一个函数如下:
{ x ( x<1 )
y={ 2x-1 ( 1<=x<10 )
{ 3x-11 ( x>=10 )
写一程序,输入x 输出y值
【c源程序】
#include <stdio.h>
int main()
{ int x,y;
printf("输入x:");
scanf("%d",&x);
if(x<1) /* x<1 */
{ y=x;
printf("x=%3d, y=x=%d\n" ,x,y);
}
else if(x<10) /* 1=<x<10 */
{ y=2*x-1;
printf("x=%d, y=2*x-1=%d\n",x,y);
}
else /* x>=10 */
{ y=3*x-11;
printf("x=%d, y=3*x-11=%d\n",x,y);
}
return 0;
}
本文链接:http://www.wb98.com/c/post/tanhaoqiang_4.6.html
本站文章搜索: