12345678910111213141516171819202122232425 |
- #include <stdio.h>
- void max_min(int n, float arr[], float *max, float *min) {
- *max = *min = arr[0];
-
- int i;
- for(i = 1; i < n; i++) {
- if(arr[i] > *max) *max = arr[i];
- if(arr[i] < *min) *min = arr[i];
- }
- }
- int main() {
- int n, i;
- scanf("%d",&n);
-
- float arr[n];
- for(i = 0; i < n; i++) scanf("%f",&arr[i]);
-
- float max,min;
- max_min(n, arr, &max, &min);
- printf("%.2f\n%.2f",max,min);
-
- return 0;
- }
|