4 条题解

  • 1
    @ 2025-7-6 20:52:17

    布尔类型

    此题要求将关系表达式 a > b的结果赋值给布尔类型的变量。而在C++当中,布尔类型需要用函数bool来进行该操作,比如: bool //此处填写变量名// ; bool变量只有两种值,分别是true(对)与 false(错)。而如果int类型(即整数类型)强转 bool类型默认大于1为true,0为false。 (PS:直接输出的同学们得加小括号) 好啦~话不多说,代码奉上!!!

    ```cpp
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
       int a,b;
       bool x;
       cin>>a>>b;
       x=(a>b);
       cout<<x;
       return 0;
    }
    

    已经AC啦~可以放心食用哦! (OvO)

    • 1
      @ 2024-11-25 17:34:17

      #include//关注b站海绵经验包谢谢喵 using namespace std; int main() { int a; int b; cin>>a>>b; bool is_bigger; is_bigger=(a>>b); cout<<is_bigger<<endl; }

      • 0
        @ 2025-9-29 17:24:00

        #include<bits/stdc++.h> using namespace std; int main(){ int a,b; bool x; cin>>a>>b; x=(a>b); cout<<x; return 0; } //关注b站 阿秋--一只小绵羊

        • 0
          @ 2024-12-15 21:43:52
          • 1

          信息

          ID
          106
          时间
          1000ms
          内存
          256MiB
          难度
          4
          标签
          (无)
          递交数
          206
          已通过
          96
          上传者