{
  "question_id": 7429364,
  "question_title": "计算英文单词的能量值",
  "question_content": "<p>【问题描述】规定26个英文字符的能量值分别是1-26&#xff0c;键盘输入一个英文单词&#xff0c;输出它的能量值。字符不区分大小写。\n【输入形式】在提示语后面输入一个单词\n【输出形式】输出energy&#61;计算值\n【样例输入1】Input a word:Integrity\n【样例输出1】energy&#61;127\n【样例输入2】Input a word:Upset\n【样例输出2】energy&#61;81\n【样例说明】下划线上是输入输出的数据&#xff0c;其余是程序的提示信息</p>",
  "difficulty": "简单",
  "answer_id": 53396246,
  "answer_content": "<pre>\n<code class=\"language-cpp\">#include &lt;stdio.h&gt;\n#include &lt;string&gt;\nusing namespace std;\n#pragma warning(disable:4996)\nint  main()\n{\n\tint i;\n\tint sum &#61; 0;\n\tchar arrs[1000];\n\tprintf(&#34;Input a word:&#34;);\n\twhile (scanf(&#34;%s&#34;, &amp;arrs) !&#61; EOF) {\n\t\tsum &#61; 0;\n\t\tfor (i &#61; 0; i &lt; strlen(arrs); i&#43;&#43;) {\n\t\t\t/// &lt;summary&gt;\n\t\t\t/// a-z 的ascii码高于 A-Z\n\t\t\t/// &lt;/summary&gt;\n\t\t\t/// &lt;returns&gt;&lt;/returns&gt;\n\t\t\tif (arrs[i] &gt; &#39;a&#39;) {\n\t\t\t\tsum &#43;&#61; arrs[i] - &#39;a&#39; &#43; 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsum &#43;&#61; arrs[i] - &#39;A&#39; &#43; 1;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tprintf(&#34;energy&#61;%d\\n&#34;, sum);\n\t\tprintf(&#34;Input a word:&#34;);\n\t\t\n\t}\n\t\n\treturn 0;\n}</code></pre>\n\n<p> <img alt=\"\" height=\"560\" src=\"https://img-ask.csdnimg.cn/upload/1620992982648.png\" width=\"802\" /></p>\n\n<p>程序运行结果&#xff1a;</p>\n\n<pre>\n<code class=\"language-cpp\">Input a word:Integrity\nenergy&#61;127\nInput a word:Upset\nenergy&#61;81\nInput a word:</code></pre>\n\n<p> </p>\n",
  "tag_name": "c语言",
  "cpp": "#include <stdio.h>\n#include <cstring>\nusing namespace std;\n#pragma warning(disable:4996)\nint  main()\n{\n\tint i;\n\tint sum = 0;\n\tchar arrs[1000];\n\tprintf(\"Input a word:\");\n\twhile (scanf(\"%s\", &arrs) != EOF) {\n\t\tsum = 0;\n\t\tfor (i = 0; i < strlen(arrs); i++) {\n\t\t\tif (arrs[i] >= 'a') {\n\t\t\t\tsum += arrs[i] - 'a' + 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsum += arrs[i] - 'A' + 1;\n\t\t\t}\n\t\t}\n\t\tprintf(\"energy=%d\\n\", sum);\n\t\tprintf(\"Input a word:\");\n\t}\n\treturn 0;\n}",
  "topic_link": "https://bbs.csdn.net/topics/600469864",
  "status": 1,
  "keywords": "算法初阶,快速排序,快速排序的描述,排序和顺序统计量",
  "license": "csdn.net",
  "notebook": {
    "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/121.ipynb?type=file"
  },
  "notebook_enable": 1,
  "author": "weixin_41623858"
}