1.单case很多清空没必要的

2.string+ char 最好用pushback

3.string +string就直接+

#include <bits/stdc++.h>
using namespace std;
typedef long long LL; const int N=2e6+10;
map<string, int> mp; string temp,res;
int num;
string s;
int n; bool Judge(char x)
{
if(x>='0'&&x<='9') return true;
if(x>='A'&&x<='Z') return true;
if(x>='a'&&x<='z') return true;
return false;
} int main()
{
getline(cin,s);
n=s.length();
bool flag = true;
int ans=0;
//mp.clear();
temp = "";
for(int i=0;i<n;i++)
{
if(s[i]>='A'&&s[i]<='Z')
s[i] = s[i] + 'a' - 'A';
if(Judge(s[i]))
{
temp.push_back(s[i]);//temp = temp + s[i];
flag=true;
}
else
{
num = temp.length();
if(num)
{
mp[temp]++;
if(mp[temp]>ans)
{
ans = mp[temp];
res = temp;
}
temp = "";
flag = false;
}
}
}
if(flag)
{
mp[temp]++;
if(mp[temp]>ans)
{
ans = mp[temp];
res = temp;
}
}
cout<<res<<" "<<ans<<endl;
return 0;
}

PAT 1071【STL string应用】的更多相关文章

  1. 深入剖析 linux GCC 4.4 的 STL string

    转自: 深入剖析 linux GCC 4.4 的 STL string 本文通过研究STL源码来剖析C++中标准模板块库std::string运行机理,重点研究了其中的引用计数和Copy-On-Wri ...

  2. 格式字符串分配stl::string

    代码非常easy,不解释,直接在代码: #include <cstdio> #include <cstdarg> #include <iostream> using ...

  3. 浅谈C++ STL string容器

    浅谈C++ STL string容器 本篇随笔简单讲解一下\(C++STL\)中\(string\)容器的使用方法及技巧. string容器的概念 其实\(string\)并不是\(STL\)的一种容 ...

  4. C++标准模板库Stand Template Library(STL)简介与STL string类

    参考<21天学通C++>第15和16章节,在对宏和模板学习之后,开启对C++实现的标准模板类STL进行简介,同时介绍简单的string类.虽然前面对于vector.deque.list等进 ...

  5. 转C++之stl::string写时拷贝导致的问题

    前几天在开发某些数据结构到文件的 Dump 和 Load 功能的时候, 遇到的一个 bug . [问题复现] 问题主要出在 Load 过程中,从文件读取数据的时候, 直接使用 fread 的去操作 s ...

  6. PAT 1071 Speech Patterns[一般]

    1071 Speech Patterns (25 分) People often have a preference among synonyms of the same word. For exam ...

  7. [转载] C++ STL string的Copy-On-Write技术

    原文: http://coolshell.cn/articles/12199.html stl的string是经过严格优化的, 深入理解对以后编程过程中应用string非常有益处, 感谢左耳朵耗子的精 ...

  8. stl string

    10.2.1 STL的string 1String概念 ²  string是STL的字符串类型,通常用来表示字符串.而在使用string之前,字符串通常是用char*表示的.string与char*都 ...

  9. [转] 深入剖析 linux GCC 4.4 的 STL string

    本文通过研究STL源码来剖析C++中标准模板块库std::string运行机理,重点研究了其中的引用计数和Copy-On-Write技术. 平台:x86_64-redhat-linux gcc ver ...

随机推荐

  1. BZOJ 1059 [ZJOI2007]矩阵游戏:二分图匹配

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1059 题意: 给你一个n*n的01矩阵. 你可以任意次地交换某两行或某两列. 问你是否可以 ...

  2. Selenium-百度登录简单例子

    实现: 百度web端登录,手动输入验证码 #! /usr/bin/env python #coding=utf-8 from selenium import webdriver import time ...

  3. FEC之异或运算应用

    话说为啥FEC需要异或( ^/⊕ )操作呢? 异或:xor 异或运算规则: 0 xor 0 = 0 0 xor 1 = 1 1 xor 0 = 1 1 xor 1 = 0 异或运算特性: 1). a ...

  4. LeetCode 510. Inorder Successor in BST II

    原题链接在这里:https://leetcode.com/problems/inorder-successor-in-bst-ii/ 题目: Given a binary search tree an ...

  5. ACM学习历程——ZOJ 3822 Domination (2014牡丹江区域赛 D题)(概率,数学递推)

    Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often ...

  6. cs2008中头文件交叉编译的问题

    使用全局变量 使用基类指针定义在头文件中,在实际使用中强制转型为需要的指针,当然应该也可以存为空指针.

  7. log4net 使用

    1. 代码中使用配置文件: log4net.Config.DOMConfigurator.Configure(new FileInfo("log4netConfig.xml")); ...

  8. asp.net异常处理和错误页配置

    最近做一个项目,直接拷贝了前辈写的程序,结果报错了查了半天都没查出原因,也看不出哪里报错,最后发现有一个错误被try...catch了,所以我们做项目的时候一般不需要try...catch. 假设所有 ...

  9. python 基础 序列化

    转自https://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/00138683221577 ...

  10. 17_点击事件第四种写法_布局文件添加onclick属性

    尽量不要用第四种点击事件的写法.在一万多行代码中发现了一个没被调用的代码 public void call(View v){//第四种写法参数一定是View v //public void call( ...