top1编程
← 返回题目
题解

【入门】四位数的计算

1 条题解

  • 0
    @ 2026-7-29 0:15:58
    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
        int n;
        cin >> n;
        // 提取前两位数字
        int x = n / 100;
        // 提取后两位数字
        int y = n % 100;
        // 输出两数之和
        cout << x + y << endl;
        // 输出两数之商,保留1位小数
        cout << fixed << setprecision(1) << (double)x / y << endl;
        return 0;
    }
    
    • 1