hdu2072(map)
来源:互联网 发布:贵州广电网络股票 编辑:程序博客网 时间:2024/06/06 20:58
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2072
解题思路:
用map建立一个string 到int的映射,每次遍历字符串,先把空格过滤掉,然后开一个string t 记录单词。每次判断m[ t ]是否已经访问过,如果没有访问过,则标记,计数器+1.
完整代码:
#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <sstream>#include <iomanip>#include <numeric>#include <cstring>#include <climits>#include <cassert>#include <complex>#include <cstdio>#include <string>#include <vector>#include <bitset>#include <queue>#include <stack>#include <cmath>#include <ctime>#include <list>#include <set>#include <map>using namespace std;#pragma comment(linker, "/STACK:102400000,102400000")typedef long long LL;typedef double DB;typedef unsigned uint;typedef unsigned long long uLL;/** Constant List .. **/ //{const int MOD = int(1e9)+7;const int INF = 0x3f3f3f3f;const LL INFF = 0x3f3f3f3f3f3f3f3fLL;const DB EPS = 1e-9;const DB OO = 1e20;const DB PI = acos(-1.0); //M_PI;string s;map<string , int> m;int main(){ #ifdef DoubleQ freopen("in.txt","r",stdin); #endif while(getline(cin , s)) { if(s == "#") break; int len = s.length(); m.clear(); int cnt = 0; for(int i = 0 ; i < len ; i ++) { if(s[i] == ' ') continue; string t = ""; for( ; i < len ; i ++) { if(s[i] != ' ') t += s[i]; else break; } if(m[t] == 0) { m[t] = 1; cnt ++; } } cout << cnt << endl; }}
0 0
- hdu2072(map)
- HDU2072-map
- hdu2072 map
- HDU2072
- HDU2072
- hdu2072
- HDU2072
- hdu2072 单词数(字典树)
- HDU2072 单词数(解法二)
- hdu2072—单词数(set)
- hdu2072单词数(c++ set集合的使用)
- hdu2072——单词数(STL,set)
- hdu2072不同单词数(STL之set函数与stream流)
- hdu2072(不同单词数)
- 单词数,hdu2072
- HDU2072:单词数
- sscanf用法详解-hdu2072
- HDU2072:单词数
- MySql入门
- chrome devtools简介
- struts2机制
- java2学习手册
- eclipse maven plugin link 插件 安装 和 配置
- hdu2072(map)
- 实现下拉列表
- JQuery Ajax向后台传递数组
- 注册DLL、OCX的方法
- JAVA实现实用的ZIP压缩与解压
- Sublime text 3 汉化破解版最新下载(3061)
- thinkphp 读取mysql数据 编辑
- PopupWindow被输入法弹上去之后无法恢复原位
- ARM 寄存器