6 条题解

  • 3
    @ 2025-3-28 19:27:18

    #include<bits/stdc++.h> using namespace std; int main() { int a,b; char c; cin>>a>>b>>c; switch(c) { case '+': cout<<a+b; break; case '-': cout<<a-b; break; case '': cout<<ab; break; case '/': if(b!=0) { cout<<a/b; break; } else { cout<<"Divided by zero!"; break; } default: { cout<<"Invalid operator!"; break; }
    } return 0; }

    • 2
      @ 2025-4-1 19:17:13
      #include<bits/stdc++.h>
      #define yy return 0;
      using namespace std;
      int main() { 
          int a,b;
          char c; 
          cin>>a>>b>>c;
          if(c=='+') cout<<a+b; 
          else if(c=='-') cout<<a-b; 
          else if(c=='*') cout<<a*b;
          else if(c=='/') { 
              if(b==0) cout<<"Divided by zero!"; 
              else cout<<a/b;
          } 
          else cout<<"Invalid operator!";
          yy
      }
      
      • 2
        @ 2025-2-12 20:35:09

        水题

        #include<bits/stdc++.h>
        #define yy return 0;
        using namespace std;
        int main() { 
            int a,b;
            char c; 
            cin>>a>>b>>c;
            if(c=='+') cout<<a+b; 
            else if(c=='-') cout<<a-b; 
            else if(c=='*') cout<<a*b;
            else if(c=='/') { 
                if(b==0) cout<<"Divided by zero!"; 
                else cout<<a/b;
            } 
            else cout<<"Invalid operator!";
            yy
        }
        • 1
          @ 2025-4-3 19:33:28
          #include<bits/stdc++.h> 
          using namespace std; 
          int main() 
          { 
              int a,b; 
              char c; 
              cin>>a>>b>>c; 
              switch(c) 
              { 
                  case '+': cout<<a+b; break; 
                  case '-': cout<<a-b; break; 
                  case '*': cout<<a*b; break; 
                  case '/': 
                  if(b!=0) {cout<<a/b; break; }
                  else cout<<"Divided by zero!"; break; 
                  default: cout<<"Invalid operator!"; break; 
              } 
              return 0; 
          }//switch-case语句
          
          • 1
            @ 2024-12-16 20:55:02

            #include<bits/stdc++.h> using namespace std; int main(){ int a,b; char c; cin>>a>>b>>c; if (c=='+') {cout<<(a+b);} else if (c=='-') {cout<<a-b; } else if (c=='') {cout<<ab; } else if (c=='/') {if (b==0) {cout<<"Divided by zero!";} else {cout<<a/b; }} else {cout<<"Invalid operator!"; } return 0; } //自己换行

            • 0

              #include<bits/stdc++.h> using namespace std; int main() { int a,b; char c; cin>>a>>b>>c; if(c=='+') { cout<<a+b; } else if(c=='-') { cout<<a-b; } else if(c=='') { cout<<ab; } else if(c=='/') { if(b==0) { cout<<"Divided by zero!"; } else { cout<<a/b; } } else { cout<<"Invalid operator!"; } return 0; } 自己换行

              • 1

              信息

              ID
              4502
              时间
              1000ms
              内存
              128MiB
              难度
              1
              标签
              (无)
              递交数
              135
              已通过
              84
              上传者