Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <locale.h>
- #include <stdlib.h>
- int main() {
- setlocale(LC_ALL, "rus");
- int *a;
- int n = 10;
- a = (int*)malloc((n-1) * sizeof(int));
- for (int i = 0; i < n-1; i++)
- scanf("%d ", &a[i]);
- int *mx = &a[0], mxi, *mn = &a[0], mni;
- for (int i = 0; i < n - 1; i++) {
- if (a[i] > *mx) {
- mx = &a[i];
- mxi = i;
- }
- }
- for (int i = 0; i < n - 1; i++) {
- if (a[i] < *mn) {
- mn = &a[i];
- mni = i;
- }
- }
- int t = *mx;
- a[mxi] = *mn;
- a[mni] = t;
- for (int i = 0; i < n; i++)
- printf("%d ", a[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement