怎样删除一维数组中的一个最小数,并且再次确定剩余数中的最小数

来源:百度知道 编辑:UC知道 时间:2024/05/26 14:53:15
用C语言编写,谢谢各位大大的指教,本人急求。请给较详细的程序过程,给出的程序最好能运行。如果满意,本人一定追加分数,不少于悬赏分……

a记录数组元素 N记录个数

#include<stdio.h>

int a[100], N;

int*find_min_element(int*begin, int*end) {
int*ret=begin, *p;
for(p=begin+1; p<end; ++p)
if(*p<*ret) ret=p;
// return the position of the min element in the range [begin,end)
return ret;
}

int*erase_element(int*pos,int*begin,int*end) {
int*p=pos;
for(;p+1<end;++p)
*p=*(p+1);
// return the position of the end of the array
return p;
}

int output(int*begin, int*end) {
int *p=begin;
for(;p<end;++p)
printf("%4d", *p);
printf("\n");
}

int main() {
int i;
// input the array
scanf("%d", &N);
for(i=0;i<N;++i) scanf("%d", a+i);

// work1
// find the position of the min element
int*p = find_min_element(a, a+N);
printf("min element = %d\n", *p);

删除一维数组中所有相同的数,使之只剩下一个,数组中的数已按由小到大顺序排列。 求助C程序编程问题 ,题目:删除一维数组中所有相同的数,使之只剩下一个,数组中的数以按由小到大的顺序排列. 如何在一维数组中利用for循环删除一个数 设计函数sort。形式参数为一个一维数组,功能对该数组中的数进行冒泡排序 如何用matlab判定 一个一维数组(矩阵)中的数互不相等 vb编程题:求数组中的最小数及其位置 编写一个子过程,求一维数组中最小的数 利用指针的方法,求数组中的最大数和最小数 程序功能是:求出3*4矩阵每列中的最小元素,并依次放入一维数组pp中。 如何将一个数(45456531221.0)拆分成一个一维数组?