12345678910111213141516171819202122232425262728293031323334 |
- #include <stdio.h>
- void max_min(float arr[], int n, float *max, float *min) {
- *max = arr[0];
- *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(arr, n, &max, &min);
- printf("%d\n", (int)max);
- printf("%d\n", (int)min);
- return 0;
- }
|