如题所述
#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",y);
return 0;
}
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",y);
return 0;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答 2014-04-02
你好,可以用if-else if-else语句实现,代码如下,望采纳:
#include <stdio.h>
int main()
{
double x;
scanf("%lf",x);
if(x<1)
printf("%lf\n",x);
else if(x<10)
printf("%lf\n",2*x-1);
else
printf("%lf\n",3*x-11);
return 0;
}
#include <stdio.h>
int main()
{
double x;
scanf("%lf",x);
if(x<1)
printf("%lf\n",x);
else if(x<10)
printf("%lf\n",2*x-1);
else
printf("%lf\n",3*x-11);
return 0;
}