remove all the same elements
2015-08-21 14:26
309 查看
[code]int remove(type x) { int size = currentsize; //currentsize 为序列中元素个数 for(int i = 0; i < currentsize; ) { if(elements[i] == x) { for(int j = i; j < currentsize; j++) elements[j] = elements[j + 1]; //将i后的元素前移一位 currentsize--; continue; //删除i后所有与x相等的元素 } i++; } if(size == currentsize) { cout << "can't find the element you want to remove!" << endl; return 0; } return 1; }
相关文章推荐
- Java中取资源时,Class.getResource和ClassLoader.getResource
- Android中验证输入是否为汉字及手机号,邮箱验证
- 【ODPS】UDF基础
- HDU 5407 CRB and Candies(LCM +最大素因子求逆元)
- HDU 1248:寒冰王座【Floyd & 完全背包】
- Spring bean reference example
- Linux常用命令
- 退出(C# Winform)
- 03-树2. List Leaves (25)
- UVA 10082 WERTYU
- 你应该掌握的七种回归技术
- 初识ps君记录~~
- 代码注释技术
- APP发布
- Android颜色代码
- 【Base64】JDK里面实现Base64的API
- spring定时器
- 彻底理解position与anchorPoint
- Android系统时间
- C++ Rand()各种实现