线性表操作
来源:互联网 发布:淘宝网十二伏鹰眼灯 编辑:程序博客网 时间:2024/05/16 15:44
/***name: create a seqlistreceive: seqlist addressreturn: int***/int creat(Seqlist* L){int len;L->length = 0;printf("Enter the length of the seqlist:");scanf("%d", &len);if (len <= 100){for (int i = 0; i < len; i++){printf("Enter the %d element of the seqlist:", (i + 1));scanf("%d", &(L->data[i]));L->length++;}return 0;}else{printf("the length overflow!");return -1;}}/***name: print the seqlistreceive: seqlistreturn: int***/int show(Seqlist L){if (L.length > 0){for (int i = 0; i < (L.length); i++)printf("%d ", L.data[i]);printf("\n");return 0;}else{printf("The seqlist is empty!");return -1;}}/***name: get a element of the seqlistreveive: seqlist, positionreturen: int***/int getelement(Seqlist L, int locate){if (locate <= L.length)return L.data[locate - 1];return -1;}/***name: insert a data to the seqlistreceive: seqlist address, insert position, insert datareturn: int***/int insert(Seqlist *L, int locate, int element){if ((L->length) < 100){for (int i = (L->length); i>locate; i--)L->data[i] = L->data[i - 1];L->data[locate] = element;L->length++;return 0;}else{printf("seqlist is full!");return -1;}}/***name: delete a element from the seqlistreceive: seqlist address, elementreturn int***/int delete_by_element(Seqlist* L, int element){for (int i = 0; i < L->length; i++){if (L->data[i] == element){for (int j = i; j < L->length; j++){L->data[j] = L->data[j + 1];}}}L->length--;return 0;}/***name: delete a element from the seqlistreceive: seqlist address, positionreturn: int***/int delete_by_position(Seqlist* L, int locate){if (locate < L->length){for (int i = (locate-1); i < L->length; i++){L->data[i] = L->data[i + 1];}}L->length--;return 0;}
0 0
- 线性表操作
- 线性表操作
- 数据结构--线性表操作
- 线性表的操作
- C++线性表操作
- 线性表操作
- C++线性表操作
- 线性表操作
- ACM 线性表操作
- 线性表操作练习
- 线性表基本操作
- 线性表的操作
- 线性表操作
- 线性表简单操作
- 线性表操作
- NOJ1004线性表操作
- 线性表操作
- 1004-线性表操作
- 教你自制触摸屏
- interactive governor study for android
- B. Sereja and Contests
- 一段图片左右箭头之上一张下一张
- 多国参与搜救失联客机 中国启动最强救援
- 线性表操作
- JDBC中解决in查询超级解决方案
- 聚簇索引
- IOS:百度地图学习3
- VS2008 断点失效的解决办法
- Java中的回调函数学习
- gtk what is gtk.def gtk.symbols
- 《算法导论》思维导图
- JS 实现汉字转拼音