chapter16test5
来源:互联网 发布:软件的营销策略 编辑:程序博客网 时间:2024/05/08 04:37
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
template<class T>
int reduce(T ar[], int n);
int main()
{
long ar[8] = { 12309, 12307, 12306, 12305, 12307, 12308, 12305, 12306 };
string say[5] = { "Big", "fish", "fish", "big", "scereaful" };
int num = reduce(ar, 8);
cout << "After reduced, we have " << num << " digit .\n";
int number = reduce(say, 5);
cout << "After reduced, we have " << number << " words .\n";
return 0;
}
template<class T>
int reduce(T ar[], int n)
{
vector<T>line;
for (int i=0; i<n; i++)
line.push_back(ar[i]);
sort(line.begin(), line.end());
line.erase(unique(line.begin(), line.end()), line.end());
return line.size();
}
#include<algorithm>
#include<vector>
using namespace std;
template<class T>
int reduce(T ar[], int n);
int main()
{
long ar[8] = { 12309, 12307, 12306, 12305, 12307, 12308, 12305, 12306 };
string say[5] = { "Big", "fish", "fish", "big", "scereaful" };
int num = reduce(ar, 8);
cout << "After reduced, we have " << num << " digit .\n";
int number = reduce(say, 5);
cout << "After reduced, we have " << number << " words .\n";
return 0;
}
template<class T>
int reduce(T ar[], int n)
{
vector<T>line;
for (int i=0; i<n; i++)
line.push_back(ar[i]);
sort(line.begin(), line.end());
line.erase(unique(line.begin(), line.end()), line.end());
return line.size();
}
0 0
- chapter16test5
- 231-e-Power of Two
- Fedora 22 NFS环境搭建
- war,jar包是啥
- mysqli_set_charset和SET NAMES优劣分析
- windows平台单机多节点mysql群笔记
- chapter16test5
- 同步对象和信号量的实现
- 百度地图
- MySQL索引背后的数据结构及算法原理
- 在android系统命令行中执行arm linux程序,出现/system/bin/sh: .xxx No such file or directory问题
- Spring Mvc 无法加载js、css文件解决办法【待补充其他优雅的方法】
- 2015年7月6日工作记录
- 88.逆序存放字符串
- 在Linux下用C扩展PHP(打包成so)的方法