解题思路:
注意事项:
参考代码:
#include<stdio.h>
#define Long 10 //改变Long的大小能输入更多的数并实现该功能
int main()
{
void in_num(int* p_nums, int size);
void handle_num(int* p_nums, int size);
void out_num(int* p_nums, int size);
int nums[Long] = {0};
int* p_nums = nums;
in_num(p_nums, Long);
handle_num(p_nums, Long);
out_num(p_nums, Long);
}
void in_num(int *p_nums,int size)
{
int i;
for (i = 0; i < size; i++)
{
scanf_s("%d", p_nums++);
}
}
void handle_num(int* p_nums, int size)
{
int i,count_max,count_min; int max = *p_nums, min = *p_nums;
for (i = 0, count_max= count_min=0; i < size; i++)
{
if (*(p_nums + i) > max)max=*(p_nums + i), count_max =i;
if (*(p_nums + i) < min)min =*(p_nums + i), count_min = i;
}
*(p_nums + count_max) = *(p_nums + Long - 1), * (p_nums + Long - 1) = max;
*(p_nums + count_min) = *p_nums, * p_nums = min;
}
void out_num(int* p_nums, int size)
{
int i;
for (i = 0; i < size; i++)
{
printf("%d ", *p_nums++);
}
}
0.0分
0 人评分
九宫重排 (C++代码)浏览:1410 |
C语言程序设计教程(第三版)课后习题7.4 (C语言代码)浏览:643 |
上车人数 (C语言代码)浏览:816 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:611 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:818 |
哥德巴赫曾猜测 (C语言代码)浏览:2562 |
幸运数 (C++代码)浏览:1309 |
K-进制数 (C语言描述,蓝桥杯)浏览:955 |
A+B for Input-Output Practice (C语言代码)浏览:505 |
一元一次方程 (C语言代码)浏览:4247 |