#include<stdio.h>
#include<stdlib.h>
int swap(int* arr);
int main(void)
{
int arr[10];
for(int i = 0 ;i<10;i++)
scanf("%d", &arr[i]);
swap(arr);
return 0;
}
int swap(int* arr)
{
int m = 0;
int n = 0;
int temp;
int max=arr[0];
int min=arr[0];
for (int i = 1; i < 10; i++)
{
if (min > arr[i])
{
min = arr[i];
m = i;
}
if (max < arr[i])
{
max = arr[i];
n = i;
}
}
temp = arr[0];
arr[0] = arr[m];
arr[m] = temp;
temp = arr[9];
arr[9] = arr[n];
arr[n] = temp;
for (int i = 0; i < 10; i++)
{
printf("%d ", arr[i]);
}
}
墨魍 2019-10-31 23:37:03 |
错误50%是在哪里?