[Problem]
输入n个数,n<=100,找到其中最小的数和最大的数
[Solution]
#include <iostream> using namespace std;int main(){ // definitionint n, max, min, data;// get datacin >> n;for(int i = 0; i < n; ++i){ cin >> data;if(i == 0){ max = data;min = data;}else{ max = max > data ? max : data;min = min < data ? min : data;}}// output resultif(n > 0){ cout << min << " " << max << endl;}return 0; }