solution.json 1.7 KB
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "ec24de171a30438d807712d827454a63",
  "keywords": "数学运算",
  "title": "商品优惠计算器",
  "desc": [
    {
      "content": "\n<p>商品优惠计算器\n使用if语句编程实现输入购货金额&#xff0c;输出实际付款金额。购货折扣率如下&#xff1a;\n购货金额≤500元 不打折\n500元&lt;购货金额≤1000元 9折\n1000元&lt;购货金额 8折</p>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "cpp"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ]
  ],
  "template": {
    "content": "#include <stdio.h>\n#include <ctype.h>\n#include <stdbool.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\nint main()\n{\n\tfloat money=0.0;\n\tfloat pay=0.0;\n\tbool run = true;\n\twhile(run)\n\t{\n\t\tprintf(\"\\n请输入购货金额:\\n\");\n\t\tscanf(\"%f\", &money);\n\t\tif(money >1000)\n\t\t{\n\t\t\tpay=money*0.8;\n\t\t\tprintf(\"打八折,应付金额:%.2f\\n\",pay);\n\t\t}\n\t\telse if((money >500)&&(money <=1000))\n\t\t{\n\t\t\tpay=money*0.9;\n\t\t\tprintf(\"打九折,应付金额:%.2f\\n\",pay);\n\t\t}\n\t\telse if(money <=500)\n\t\t{\n\t\t\tprintf(\"不打折,应付金额:%.2f\\n\",money);\n\t\t}\n\t}\n\treturn 0;\n}",
    "language": "cpp"
  },
  "node_id": "dailycode-9b2837c3037b460e9a6fef477307ca55",
  "license": "csdn.net",
  "created_at": 1637894160,
  "topic_link": "https://bbs.csdn.net/topics/600470151"
}