有道题写出来感觉上没问题,可就是出错不知道为什么
#include <stdio.h>
main()
{int x,y;
scanf("%d",&x);
if(x<1) y=x;
if(x>=1&&x<10) y=2x-11;
if(x>=10) y=3x-11;
printf("%d\n",y);}
[解决办法]
#include <stdio.h>
int main()
{
int x,y;
scanf("%d",&x);
if(x < 1) y = x;
if(x >= 1 && x < 10) y = 2*x-11;
if(x >= 10) y = 3*x-11;
printf("%d\n",y);
}
[解决办法]
这样试试:
#include <stdio.h>
main()
{
int x,y;
scanf("%d",&x);
if(x < 1)
y = x;
if(x >= 1 && x < 10)
y = 2 * x-11; //*
if(x >= 10)
y = 3 * x-11;//*
printf("%d\n", y);
}