编程知识 cdmana.com

我用if语句写了一个程序,能不能帮我看看为什么运行不了?

#include<stdio.h>
int main(void)
{
float x,y;

scanf("%f",x);if(x<1){    y=x;    printf("y=%f\n",y);}else if(x>=1&&x<10){    y=2*x-1;    printf("y=%f\n",y);}else {    y=3*x-11;    printf("y=%f\n",y);}return 0;

}




参考答案1:

scanf("%f",&x);

#include<stdio.h>int main(void){float x,y;scanf("%f",&x);if(x<1){    y=x;    printf("y=%f\n",y);}else if(x>=1&&x<10){    y=2*x-1;    printf("y=%f\n",y);}else {    y=3*x-11;    printf("y=%f\n",y);}      return 0;}



参考答案2:



参考答案3:

scanf("%f", &x);
&别忘了




参考答案4:

版权声明
本文为[CSDN问答]所创,转载请带上原文链接,感谢
https://ask.csdn.net/questions/7577112

Scroll to Top