跳至正文

1 条题解

  • 0
    @ 2026-10-7 23:31:08

    【本题解由站长编写】

    按输出顺序先打印提示语,再分别读入实数与字符串,最后用 %g 输出实数(自动去掉多余零)并输出字符串。

    代码(C++17)

    #include <bits/stdc++.h>
    using namespace std;
    int main() {
        double x;
        string s;
        cout << "please input a number:\n";
        cin >> x;
        cout << "please input a string:\n";
        cin >> s;
        printf("%g\n", x);
        cout << s << endl;
        return 0;
    }
    
    • 1

    信息

    ID
    4129
    时间
    1000ms
    内存
    512MiB
    难度
    6
    标签
    递交数
    0
    已通过
    0
    上传者