{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "5a97ea92895d4fdda13359eeae09f284",
  "keywords": "算法高阶,字符串匹配,算法问题选编,利用有限自动机进行字符串匹配",
  "title": "任意多行字符串拆分数值求和",
  "desc": [
    {
      "content": "\n<pre><p>编写程序&#xff0c;统计每行字符串中若干整数的和。每行字符串中整数间的分隔符可能有逗号“,”、分号“ ;”和空格&#xff0c;有多少行就求多少行。\n输入格式:\n任意输入若干行由整数构成的字符串&#xff08;回车换行&#xff09;&#xff0c;整数间以逗号或空格或分号分隔。测试数确保至少有一行数据&#xff0c;字符串中的整数数据均合法有效。最后以一个回车结束输入。\n输出格式:\n对应输出原输入串&#xff08;一行中的字符序列&#xff09;&#xff0c;冒号后输出各个整数之和。\n</pre><p>输入样例:</p></p>\n<pre>\n<code>1; 2 ,3\n2 3; 4\n10,20 30; 40\n9</code></pre>\n<p>输出样例:</p>\n<pre>\n<code>1; 2 ,3:6\n2 3; 4:9\n10,20 30; 40:100</code></pre>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "python"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ]
  ],
  "template": {
    "content": "stopword = ''  \ns = ''\nprint('请输入内容,输入空行回车结束输入：')\nfor line in iter(input, stopword):\n\ts = s + line + \"\\n\"\nprint(s)\nl = s.splitlines()\nfor num in range(0, len(l)):\n\tone = l[num].replace(',', ' ').replace(';', ' ').split()\n\tonesum = 0\n\tfor i in range(0, len(one)):\n\t\tonesum = onesum + int(one[i])\n\tprint(l[num] + \":\" + str(onesum))",
    "language": "python"
  },
  "node_id": "dailycode-45221df1b0024a78bfef72b49e99492c",
  "license": "csdn.net",
  "created_at": 1637894161,
  "topic_link": "https://bbs.csdn.net/topics/600470501"
}