2022023304


私信TA

用户名:dotcpp0646319

访问量:2933

签 名:

等  级
排  名 18581
经  验 700
参赛次数 0
文章发表 4
年  龄 0
在职情况 学生
学  校 南京航空航天大学金城学院
专  业

  自我简介:

TA的其他文章

解题思路:

声明两个变量x,y,其中x 获取用户输入,y根据函数获取赋值。
注意事项: 

1,函数中“1<=x<10"在if 条件语句中要写成”x>=1&&x<10“。

2,”2x-1“”3x-11“两个式子写成代码要将乘号写出,即"2*x-1"与"3*x-11"。

参考代码:

#include<stdio.h>

int main()

{

    int x,y;

    scanf("%d",&x);

    if(x<1)

       {y=x;}

    if(x>=1&&x<10)

       {y=2*x-1;}

    if(x>=10)

       {y=3*x-11;}

    printf("%d",y);

    return 0;

}


 

0.0分

12 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

#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
	y=3*x-11;
	printf("%d\n",y);
	return 0;
}
2024-03-18 09:41:33
#include <stdio.h>
int fun(int x){
    if(x<1)
    {
        return x;
    }
    if(x<=10 && x>=1)
    {
        return 2*x-1;
    }
    if(x>=10)
    {
        return 3*x-11;
    }
}
int main(){
    int x;
    scanf("%d",&x);
    printf("%d",fun(x));
    return 0;
}
2024-02-27 13:24:17
为什么我的程序只有一半对
求大佬帮我看看
#include<stdio.h>
int main(void)
{
	int x,y;
	scanf("%d",&x);
	if(x<1)
	{
		y=x;
		printf("%d",y);
	}
	if(x>=1&&x<10)
	{
		y=2*x-1;
		printf("%d",y);
	}
	else
	{
		y=3*x-11;
		printf("%d",y);
	}
return 0;
}
2024-01-22 21:58:10
#include<stdio.h>

int main()

{

    int x,y;

    scanf("%d",&x);

    if(x<1)

       {y=x;}

    if(x>=1&&x<10)

       {y=2*x-1;}

    if(x>=10)

       {y=3*x-11;}

    printf("%d",y);

    return 0;

}
2023-11-12 16:50:10
#include<stdio.h>
int main(){
    int x,y;
    scanf("%d",&x);
    if(x<1)
    {y=x;}
    if(x>=1&&x<10);
    {2*x-1;}
    if(x>=10)
    (3*x-11;)
    pintf("%d",y);
    return 0;
}
哪错了
2023-11-10 20:51:54
  • «
  • 1
  • »