想问一下这俩有啥区别吗?第二个系统告知未考虑所有情况,但是这和第一个不是一样的吗,第一个就行,第二个为什么不行呀?
#include
int main()
int x,y;
scanf("%d" ,&x);if(x<1)
y=х;
else if(x>=1&&x<10)y=2x-1;
else if(x>=10)
y=3x-11;
printf("%dln",y);
return0;
#include
int х,y;
scanf("%d" ,&x);
if(x<1)
y=x;
else if(x>=1&&x<10)
y=2x-1;
else (x>=10);
у=3x-11;
printf("%dln",y);
return0:
错误见注释,供参考:
#include <stdio.h>
int main()
{
int x, y;
scanf("%d", &x);
if (x < 1)
y = x;
else if (x >= 1 && x < 10)
y = 2 * x - 1;
else if (x >= 10)
y = 3*x - 11;
printf("%d\n", y);
return 0;
}
#include <stdio.h>
int main()
{
int x, y;
scanf("%d", &x);
if (x < 1)
y = x;
else if (x >= 1 && x < 10)
y = 2 * x - 1;
//else (x>=10);//; 这里多了';' 分号,else 后面少了if
else if (x >= 10)
y = 3 * x - 11;
printf("%d\n", y);
return 0;
}
第二段最后if(x>10)后面的分号删掉