Title Description
Description
Enter n number, n<=100, find the smallest and largest number
Enter a description
Input Description
First line an integer n
Next line n integers, each integer less than 231-1
Output description
Output Description
Minimum and maximum number
Sample input
Sample Input
4
1 2 3 4
Sample output
Sample Output
1 4
Data range and Tips
Data Size & Hint
No
Idea: This problem is relatively simple, you can put all the numbers into the array, and then a little use of the fast line can be finished, the output of the No. 0 and the first n-1
The code is as follows:
1#include <stdio.h>2#include <stdlib.h>3 intFunConst void*a,Const void*b)4 {5 return*(int*) a-* (int*) b;6 }7 intMain ()8 {9 intn,i;Ten inta[10000]; Onescanf"%d",&n); A for(i=0; i<n;i++) - { -scanf"%d",&a[i]); the } -Qsort (A,n,sizeof(int), fun); -printf"%d%d\n", a[0],a[n-1]); - return 0; +}
code[vs]-minimum and maximum number-integer processing-Ladder Bronze