{
  "question_id": 1071974,
  "question_title": "输入两个小写英语字母后， 输出两个字母的差",
  "question_content": "两个小写字母的差用整数输出。\n但是，输入小写以外的文字就结束程序。\n比较两个字母的部分用diff这个名字的函数书写。执行结果\n请输入两个小写：a b\n字母a和字母b的区别是1。\n请输入两个小写：f b\n字母f和字母b的差异是4。\n请输入两个小写：0 a\n退出程序。",
  "difficulty": "简单",
  "answer_id": 1274118,
  "answer_content": "\n```\n#include <iostream>\nusing namespace std;\nint diff(char ch1, char ch2)\n{\nif (ch1 > ch2) return ch1 - ch2; else return ch2 - ch1;\n}\nint main()\n{\nchar a, b;\nwhile (1)\n{\ncout << \"请输入两个小写：\";\ncin >> a >> b;\nif (a >= 'z' || a <= 'a' || b >= 'z' || b <= 'a') break;\ncout << \"文字\" << a << \"和文字\" << b << \"的差异是\" << diff(a, b) << \"。\\n\";\n}\nreturn 0;\n}\n```\n# 问题解决的话，请点下采纳",
  "tag_name": "c++",
  "cpp": "#include <iostream>\nusing namespace std;\nint diff(char ch1, char ch2)\n{\n\tif (ch1 > ch2) return ch1 - ch2; else return ch2 - ch1;\n}\nint main()\n{\n\tchar a, b;\n\twhile (1)\n\t{\n\t\tcout << \"请输入两个小写：\";\n\t\tcin >> a >> b;\n\t\tif (a > 'z' || a < 'a' || b > 'z' || b < 'a') break;\n\t\tcout << \"文字\" << a << \"和文字\" << b << \"的差异是\" << diff(a, b) << \"。\\n\";\n\t}\n\treturn 0;\n}",
  "topic_link": "https://bbs.csdn.net/topics/600470248",
  "status": 1,
  "keywords": "B树,算法高阶,高级数据结构,B树上的基本操作",
  "license": "csdn.net",
  "notebook": {
    "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/10.ipynb?type=file"
  },
  "notebook_enable": 1,
  "author": "hnwzjcds"
}