hyf


私信TA

用户名:hyf31

访问量:5267

签 名:

加油!

等  级
排  名 683
经  验 3833
参赛次数 5
文章发表 11
年  龄 13
在职情况 学生
学  校 XS
专  业

  自我简介:

在校学生

TA的其他文章

参考代码:

#include<iostream>
using namespace std;
int f(int x)
{
   if(x<1)return x;
   if(x>=1&&x<10)return 2*x-1;
   if(x>=10)return 3*x-11;
}
int main( )
{
   int x;
   cin>>x;
   cout<<f(x)<<endl;
   return 0;
}


 

0.0分

8 人评分

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

编程语言转换

万能编程问答

代码解释器

  评论区

#include<iostream>
using namespace std;
int main()
{
    int x, y;
    while (cin >> x )
    {
        if (x < 1) { y = x; }
        if (1 <= x&&x < 10) { y = 2*x - 1; }
        if (x >= 10) { y = 3*x - 11; }
        cout << y << endl;
    }
    return 0;
}
2020-11-29 17:37:11
  • «
  • 1
  • »