#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #define MaxSize 50 typedef int ElemType ; //定义顺序表 typedef struct{ ElemType data[MaxSize]; int length; }SqList; //初始化顺序表 void InitList(SqList &L){ for(int i=0;i<MaxSize;i++){ L.data[i]=0; } L.length=0; } //P17 1 int deleteElement(SqList &L){ int i,temp=0,min=L.data[0]; if(L.length>0){ for(i=0;i<L.length;i++){ if(L.data[i]<min){ min=L.data[i]; temp=i; } } L.data[temp]=L.data[L.length-1]; }else{ printf("Error!\n"); } return min; } int main() { SqList L; InitList(L); L.length=10; for(int i=0;i<=L.length;i++){ L.data[i]=9-i; } int num=deleteElement(L); printf("%d\n",num); return 0; }
07-28
1245
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-03
4万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-19
412
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-04
2004
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)