这边的话没有考虑传参问题,直接用的全局变量,直接修改数组内容就可以了。
#include<stdio.h>
int a[10];
int max, min;
void input()
{
int i = 0;
while (i < 10)
{
scanf("%d",&a[i]);
i++;
}
}
void process()
{
int temp,k = 0;
min = a[0];
max = a[9];
for (int i = 1; i < 10; i++)
{
if (a[i] < min)
{
min = a[i];
k = i;
}
}
temp = a[0];
a[0] = a[k];
a[k] = temp;
k = 9;
for (int i = 0; i < 9; i++)
{
if (a[i] > max)
{
max = a[i];
k = i;
}
}
temp = a[9];
a[9] = a[k];
a[k] = temp;
}
void output()
{
int i = 0;
while (i < 10)
{
printf("%d ", a[i]);
i++;
}
}
int main()
{
input();
process();
output();
system("pause");
return 0;
}
0.0分
0 人评分