首页 > 编程知识 正文

string数组删除某个元素,stack around the variable

时间:2023-05-05 12:31:31 阅读:39323 作者:1503

具有相同比较函数的所有元素都将被删除

c.erase(elem ) )。

删除与elem相等的所有元素,并返回已删除元素的数量。

c.erase (销售点)

删除迭代器pos指向的位置元素。 没有返回值。

c .错误(beg,end ) ) ) )。

删除区间[beg,end的所有元素,没有返回值。

# include iostream # includesetusingnamespacestd; classstru{Public:stru(inta,int b ) :x(a ),y (b ) ) int b; int y; (; Booloperator(conststrua,const stru b )//比较的是x的值) { return a.x b.x; }创建} int main ()多址stru ST;//插入ST.insert (stru ) (9,40 ); //添加成功。 因为multiset可以有重复的值。 也就是说,可以有x=10的stru。 ST.insert (stru (9,41 ); //ST.insert (成功添加stru (10,42 ); ST.insert (stru (10,43 ); 查看//for (autoit=ST.rbegin ); it!=st.rend (; it )/10-409-439-458-407-356-305-254-203-152-101-50-0 cout (* it ).x'-' ) it ).y '; coutendl; ST.erase (stru (10,43 ); //和以上一样,只查找x=9的第一个项目。 查看//for (autoit=ST.rbegin ); it!=st.rend (; it )/10-409-439-458-407-356-305-254-203-152-101-50-0 cout (* it ).x'-' ) it ).y '; coutendl; }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。