题解 | #求最大最小数#
求最大最小数
https://www.nowcoder.com/practice/82e5ff335eeb486aab359767895cc7b4
#include <iostream> using namespace std; int main() { int N; while (scanf("%d", &N) != EOF) { // 注意 while 处理多个 case int max,min; int num; for(int i = 0; i < N; i++){ scanf("%d", &num); if(0 == i){ max = num; min = num; }else{ if(num > max){ max = num; } if(num < min){ min = num; } } } printf("%d %d\n", max, min); } } // 64 位输出请用 printf("%lld")