4 条题解

  • 5
    @ 2023-6-21 19:28:51
    #include <iostream>
    using namespace std;
    int main()
    {
        long long a,b;
        cin>>a>>b;
        long long s;
        long long y;
        s=a/b;
        y=a-s*b;//有点搞笑
        cout<<s<<" "<<y;
        return 0;
    }
    
    • 2
      @ 2024-5-26 16:35:12
      #include <bits/stdc++.h>
      using namespace std;
      int a,b;
      int main()
      {
          cin >> a >> b;
          cout << a / b << " " << a % b;
          return 0;
      }
      
      • -1
        @ 2023-5-29 19:48:18

        ##解析: 这道题主要考察的就是/和%的用法与区别,在int类型的运算中/是求商,%是求余数;题目要求先输出商,空格后输出余数,那么就需要变量a,ba,b,先a/ba/b之后aa%bb

        ##参考代码:

        #include <bits/stdc++.h>
        using namespace std;
        int main()
        {
            int a,b;//定义变量除数、被除数
            cin >> a >> b;
            cout << a / b << " " << a % b;//先求商空格后求余
            return 0;
        }
        
        • -1
          @ 2023-5-21 16:00:31

          这道题可以先用除法求出商,再用取余来求出余

          #include<bits/stdc++.h>
          using namespace std;
          int a,b;//新建两个变量,分别代表被除数和除数
          int main(){
          	cin>>a>>b;//输入被除数和除数
          	cout<<a/b<<' '<<a%b<<endl;//a/b算出商,a%b算出余
          	return 0;
          }
          
          
          
          • 1

          信息

          ID
          110
          时间
          1000ms
          内存
          128MiB
          难度
          4
          标签
          递交数
          4334
          已通过
          1836
          上传者