{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "37e3b85ac0fd4586ae7e18a4cac5a70f",
  "keywords": "算法高阶,计算几何学,算法问题选编,确定任意一对线段是否相交",
  "title": "实现五则运算",
  "desc": [
    {
      "content": "\n<pre><p>设计一个可以完成任意五则运算&#xff08;加法/减法/乘法/除法/取余&#xff09;的程序。除法按照计算机中<strong>整型相除</strong>来计算。\n输入格式\n多行输入&#xff0c;每输入一行数据对应输出一行。\n每行输入格式为 a # b&#xff0c;其中 &#xff03;∈{&#43;,−,∗,/,%}\na,b均为自然数\n输出格式\n每行输出对应的计算结果&#xff1b;\n当运算为除法/取余的时候&#xff0c;如果除数为 0 &#xff0c;输出 <code>WA</code> 。</pre>\n<p>输入样例</p>\n<pre>\n<code>2&#43;2\n4*5\n6/7\n4%3\n4%0</code></pre>\n<p>输出样例</p>\n<pre>\n<code>4\n20\n0\n1\nWA</code></pre>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "cpp"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ]
  ],
  "template": {
    "content": "#include<stdio.h>\nint main()\n{\n\tint a;\n\tint b;\n\tchar operation;\n\tint num;\n\twhile (scanf(\"%d\", &a) != EOF)\n\t{\n\t\tscanf(\"%c\", &operation);\n\t\tscanf(\"%d\", &b);\n\t\tif (operation == '+')\n\t\t{\n\t\t\tnum = a + b;\n\t\t\tprintf(\"%d\\n\", num);\n\t\t}\n\t\telse if (operation == '-') {\n\t\t\tnum = a - b;\n\t\t\tprintf(\"%d\\n\", num);\n\t\t}\n\t\telse if (operation == '*') {\n\t\t\tnum = a * b;\n\t\t\tprintf(\"%d\\n\", num);\n\t\t}\n\t\telse if (operation == '/' && b != 0) {\n\t\t\tnum = a / b;\n\t\t\tprintf(\"%d\\n\", num);\n\t\t}\n\t\telse {\n\t\t\tprintf(\"%s\\n\", \"WA\");\n\t\t}\n\t}\n\treturn 0;\n}",
    "language": "cpp"
  },
  "node_id": "dailycode-e8317165a816402db457837074d998f8",
  "license": "csdn.net",
  "created_at": 1637894160,
  "topic_link": "https://bbs.csdn.net/topics/600470274"
}