数组去重
来源:互联网 发布:网店管家数据库 编辑:程序博客网 时间:2024/04/26 14:40
int uniq_element(int* a, int len){if(len <= 1){return len;}hash_set<int> myset;//数据插入hashsetfor (int i=0; i<len; i++) myset.insert(a[i]); return myset.size();}
int uniq_element(int* a, int len){ if(len <= 1) { return len; } set<int> myset; //数据插入set for (int i=0; i<len; i++) myset.insert(a[i]); return myset.size();}
int uniq_element(int* a, int len){if(len <= 1){return len;}//数组存入vector容器vector<int> myvector (a, a + len);vector<int>::iterator it;//排序sort(myvector.begin(), myvector.end());//去重it = unique (myvector.begin(), myvector.end()); //重置sizemyvector.resize( it - myvector.begin() ); return myvector.size();}
int uniq_element(int* a, int len){if(len <= 1){return len;}int num = 1; //保存独立元素个数int i, j; //暴力比较咯for(i = 1; i < len; i++){for(j = i - 1; j >= 0; j--){if(a[j] == a[i]){break;}else{continue;}}if(-1 == j){num++;}}return num;}int _tmain(int argc, _TCHAR* argv[]){int a[] = {1,2,3,1,2,3,3};int count = uniq_element(a, sizeof(a) / sizeof(int));cout << count << endl;system("pause");return 0;}
- 数组去数组重
- 数组去重,json数组去重
- 数组去重
- 数组去重
- JS 数组去重
- 数组去重算法
- 数组去重
- js数组去重
- php 数组去重
- 数组去重
- 数组排序去重
- javascript数组去重
- json数组去重
- 数组去重
- php数组去重
- 数组如何去重
- iOS 数组去重
- 动态数组去重
- TSL/SSL基本工作原理
- 新博客安家了
- 介绍一下OGC、WMS、WFS、WCS等几个概念
- 什么是反馈电路?反馈有什么作用?
- 约瑟夫问题
- 数组去重
- hash函数
- 全局热键
- tc2.0环境下的C语言研究-函数如何接收不定数量参数
- 使用layered窗口实现界面动画
- 购物网第二阶段总结笔记2:留言薄
- select与epoll,多路IO复用
- Java操作XML(使用org.w3c.dom)
- MFC中自定义消息