双分支运算

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n>=10)
    {
         cout<<fixed<<setprecision(1)<<n*2.0<<endl;
}
    else
    {
         cout<<fixed<<setprecision(1)<<n*2.2<<endl;
    }
    return 0;
}   

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n>0)
    {
         cout<<"是正数"<<endl;
    }
    else
    {
        cout<<"不是正数"<<endl;
    }
  return 0;
}   

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int t ;
    cin>>t;
    if(t>=20 && t<=30)
    {
         cout<<"OK";
}
    else
    {
        cout<<"no";
    }
    return 0;
}   

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n <= 10 && n >= 10)
    {
         cout<<fixed<<setprecision(1)<<n*2.5<<endl;
}
    else
    {
         cout<<fixed<<setprecision(1)<<n*2.5+1.5<<endl;
    }
    return 0;
}   

#include<iostream>
#include<iomanip>
using namespace std;
int main()

{
    int t;
    cin>>t;
    if(2000<=n && n<=10000)
    {
         cout<<"ok"<<endl;
}
    else
    {
        cout<<"no"<<endl;
    }


    return 0;
}   

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n>=1.3)
    {
         cout<<fixed<<setprecision(1)<<n*60<<endl;
}
    else
    {
         cout<<fixed<<setprecision(1)<<n*120<<endl;
    }
    return 0;
}   

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    int j;
    int y;
    cin>>n;
    cin>>j;
    cin>>y;
    if(n+j>y && j+y>n)
    {
         cout<<"yes"<<endl;
}
    else
    {
         cout<<"no"<<endl;
    }
    return 0;
}   

​

​
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int m;
    int n;
    cin>>m;
    cin>>n;
    if(m*m>m*n)
    {
         cout<<m*m-m*n<<endl;
}
    else
    {
         cout<<m*n<<endl;
    }
    return 0;
}   

​

​
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    int x;
    cin>>n;
    cin>>x;
    if(n <= 10 && x <= 100 && x>=100)
    {
         cout<<n/x<<endl;
}
    else
    {
         cout<<n/x+1<<endl;
    }
    return 0;
}   

​

​
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int A;
    int B;
    cin>>A;
    cin>>B;
    if(A > B && A < B)
    {
         cout<<"A>B"<<endl;
}
    else
    {
         cout<<"A<B"<<endl;
    }
    return 0;
}   

​

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n; 
    cin>>n;
    if(n%30 == 0)
    {
         cout<<n/30<<endl;
}
    else
    {
        cout<<n/30+1<<endl;
    }
    return 0;
}   

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n>=200)
    {
         cout<<fixed<<setprecision(1)<<n*0.8<<endl;
}
    else
    {
         cout<<fixed<<setprecision(1)<<n*0.9<<endl;
    }
    return 0;
}   

​
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int aw;
    int jy;
    cin>>aw;
    cin>>jy;
    if(aw > jy && aw < jy)
    {
         cout<<aw<<endl;
}
    else
    {
         cout<<jy<<endl;
    }
    return 0;
}   

​

​
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int dg;
    int zq;
   
    cin>>dg;
    cin>>zq;
    
    if(dg >= zq && dg <= zq)
    {
         cout<<fixed<<setprecision(1)<<dg<<endl;
}
    else
    {
         cout<<fixed<<setprecision(1)<<zq<<endl;
    }
    return 0;
}   

​

'

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(x y z >= 90 x y z <= 90 )
    {
         cout<<"beijing"<<endl;
}
    else
    {
         cout<<"nanjing"<<endl;
    }
    return 0;
}   

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;  
    cin>>n;
    int g = n%10;
    int b = n/100%10;
    if(g == b)
    {
         cout<<"yes"<<endl;
}
    else
    {
        cout<<"no"<<endl;
    }
    return 0;
}   

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int h = n%10;
    int z = n/10%10;
    int q = n/100%10;
    int w = n/1000%10;
    int b = n/10000%10;
    int y = n/100000
    if(h == z == q == w == b == y)
    {
         cout<<"yes"<<endl;
}
    else
    {
        cout<<"no"<<endl;
    }
    return 0;
}   

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n<=10 && n>=10)
    {
         cout<<fixed<<setprecision(1)<<n*1.5<<endl;
}
    else
    {
         cout<<fixed<<setprecision(1)<<n*1.2<<endl;
    }
    return 0;
}   

​
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int s,q,w,j,y,z;
    cin>>s,q,w,j,y,z;
    if(s == q == w == j == y == z)
    {
         cout<<s,q,w<<endl;
}
    else
    {
         cout<<j,y,z<<endl;
    }
    return 0;
}   

​

### 三级标题:双分支结构的基本概念 在C++中,双分支结构是一种选择结构,它根据条件的真假来决定执行哪一段代码。这种结构通常使用 `if-else` 语句来实现。`if` 语句用于检查条件是否为真,如果条件为真,则执行 `if` 块中的代码;否则,执行 `else` 块中的代码。这种结构允许程序在两个不同的路径之间做出选择。 ### 三级标题:双分支结构的语法 双分支结构的基本语法如下: ```cpp if (condition) { // 如果条件为真,执行这里的代码 } else { // 如果条件为假,执行这里的代码 } ``` 在这个结构中,`condition` 是一个布尔表达式,其结果为真(非零)或假(零)。如果 `condition` 为真,则执行 `if` 块中的代码;否则,执行 `else` 块中的代码。 ### 三级标题:逻辑运算符的应用 在双分支结构中,逻辑运算符可以用来组合多个条件。例如,逻辑与 `&&` 可以用来检查两个条件是否都为真,而逻辑或 `||` 可以用来检查至少有一个条件为真。逻辑非 `!` 则用来反转条件的结果。 ```cpp int x = 0; cin >> x; bool flag1 = !(x & 1); // 检查x是否为偶数 bool flag2 = (x > 4 && x <= 12); // 检查x是否在5到12之间 ``` ### 三级标题:双分支结构的示例 下面是一个使用双分支结构的示例,它根据用户输入的数字来判断该数字是否为偶数以及是否在特定范围内: ```cpp #include <iostream> using namespace std; int main() { int x = 0; cin >> x; bool flag1 = !(x & 1); // 检查x是否为偶数 bool flag2 = (x > 4 && x <= 12); // 检查x是否在5到12之间 cout << (flag1 & flag2) << " "; // 输出1如果x是偶数且在5到12之间,否则输出0 cout << (flag1 | flag2) << " "; // 输出1如果x是偶数或在5到12之间,否则输出0 cout << (flag1 ^ flag2) << " "; // 输出1如果x是偶数或在5到12之间但不同时满足,否则输出0 cout << (!flag1 & !flag2); // 输出1如果x既不是偶数也不在5到12之间,否则输出0 return 0; } ``` ### 三级标题:双分支结构的逻辑运算 在上面的示例中,逻辑运算符 `&`(按位与)、`|`(按位或)、`^`(按位异或)和 `!`(逻辑非)被用来组合两个布尔标志 `flag1` 和 `flag2`。这些运算符的结果取决于两个标志的状态,并且可以用来实现复杂的条件判断。 ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值