新手求大神帮忙注释下下面这段代码。
输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组。#include <stdio.h>
void main()
{
int number[10];
input(number);
max_min(number);
output(number);
}
int input(number)
int number[10];
{
int i = 0;
for (i = 0; i < 9; i ++)
{
scanf("%d",&number[i]);
scanf("%d",&number[9]);
}
}
int max_min(array)
int array[9];
{
int *max,*min;
int k = 0;
int l = 0;
int *p,*arr_end;
arr_end = array + 10;
max = min = array;
for (p = array + 1;p < arr_end; p ++)
{
if (*p > *max)
{
max = p;
}
else if (*p < *min)
{
min = p;
}
k = *max;
l = *min;
*p = array[0];
array[0] = l;
l = *p;
*p = array[9];
array[9] = k;
k = *p;
return;
}
}
int output(array)
int array[10];
{
int *p;
for (p = array; p < array + 9; p ++)
{
printf("%d",*p);
printf("%d\r\n",array[9]);
}
return 0;
}