C程序设计第四章作业6
目录:程序员成长之旅/C语言/习题(C语言程序设计)/第四章习题
问:
输入x 求y,要求如下:
🖼 图片占位(归档模式)图片见原始导出:
C%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1%E7%AC%AC%E5%9B%9B%E7%AB%A0%E4%BD%9C%E4%B8%9A6.assets/clip_image00261c598f4-0668-4d1f-8aa7-5c7af447adb5.png答:
#include<stdio.h>
int main()
{
int x=0000.0000, y=0000.0000, Error1=0;
Error1 = scanf("%d", &x);
if (Error1 == 0)
{
setbuf(stdin, NULL);
printf("You enter data is error!\n");
exit();
}
if (x < 1)
{
printf("You enter X:[%d],Y:[%d]\n", x, y);
}
else if (x >= 1 && x < 10)
{
printf("You enter X:[%d],Y:[%d]\n", x, 2*x-1);
}
else if (x >= 10)
{
printf("You enter X:[%d],Y:[%d]\n", x, 3*x-11);
}
else
{
setbuf(stdin, NULL);
printf("You enter data is error!\n");
}
return 0;
}