{ "question_id": 1067964, "question_title": "找最大数和最小数", "question_content": "编写程序,设置正整数n的值,其中n取值为小于等于10的正整数,再继续输入n个整数数值,从n个整数中找出最大数和最小数,并将它们输出。\n输入格式:\nn的数值(取值为1-10整数)\nn个具体整数值\n输出格式:\n最大值\n最小值\n输入样例1:\n4 \n8 3 4 1 \n输出样例1:\n8\n1\n输入样例2:\n5\n-1 6 3 2 0\n输出样例2:\n6\n-1", "difficulty": "简单", "answer_id": 1268432, "answer_content": "\n```\n#include \nusing namespace std;\nint main()\n{\nint n;\ncin >> n;\nint ma, mi, a;\ncin >> a;\nmi = ma = a;\nfor (int i = 1; i < n; i++)\n{\ncin >> a;\nif (ma < a) ma = a;\nif (mi > a) mi = a;\n}\ncout << ma << endl << mi << endl;\n}\n```\n\n# 问题解决的话,请点下采纳", "tag_name": "c++", "cpp": "#include \nusing namespace std;\nint main()\n{\n\tint n;\n\tcin >> n;\n\tint ma, mi, a;\n\tcin >> a;\n\tmi = ma = a;\n\tfor (int i = 1; i < n; i++)\n\t{\n\t\tcin >> a;\n\t\tif (ma < a) ma = a;\n\t\tif (mi > a) mi = a;\n\t}\n\tcout << ma << endl << mi << endl;\n}", "topic_link": "https://bbs.csdn.net/topics/600470161", "status": 1, "keywords": "算法初阶,最小值和最大值,排序和顺序统计量,中位数和顺序统计量", "license": "csdn.net", "notebook": { "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/58.ipynb?type=file" }, "notebook_enable": 1 }