用C语言编写程序

如题所述

#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;
}
温馨提示:答案为网友推荐,仅供参考
第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;
}

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网