摘要: 假设整数为INT型,且非负数,代码如下:注意点:GetInersection返回值应该为vector而不应该是vector& 因为vector向量对象在函数运行完后系统会自动的调用析构函数,如果返回&的话,将得到一个NULL值#include #include #include #includeusing namespace std;//求集合a和集合b的交集vector GetIntersection(seta,setb){ bitset bs(0);//创建一个位数组来存储a中存在的数 vectorc;//创建向量来存储交集中的元素 //把a中存在的数值作为c的下标,标记. 阅读全文
posted @ 2013-10-03 15:19 宁静致远--Ada 阅读(643) 评论(0) 推荐(0) 编辑