找最大最小整数.c 304 B

123456789101112131415161718192021222324
  1. #include <stdio.h>
  2. int main() {
  3. int inputnum,num,max,min,i = 2;
  4. scanf("%d",&inputnum);
  5. scanf ("%d",&num);
  6. max = min = num;
  7. while(i <= inputnum) {
  8. scanf("%d",&num);
  9. if(num > max) {
  10. max = num;
  11. }
  12. if(num < min) {
  13. min = num;
  14. }
  15. i += 1;
  16. }
  17. printf("%d %d",max,min);
  18. return 0;
  19. }