Hiho 1385 模拟,细节
来源:互联网 发布:mac 查看沙盒软件 sim 编辑:程序博客网 时间:2024/06/06 07:07
1 一定要让思路和代码,保持简介清晰条理
2 如果这个思路写不下去,就换思路重写不要卡在一个思路上太久,可以换个数据结构或者代码组织形式
3 如何才能将各种细节尽可能都想到呢。
#include<stdio.h>//#include<bits/stdc++.h>#include<string.h>#include<iostream>#include<map>using namespace std;string s;map<string,int>mmat;map<string,int>::iterator it;void Print(){ int minn=0; for(it=mmat.begin();it!=mmat.end();it++){ //cout<<"Note1: "<<it->first<<" "<<it->second<<endl; if(it->second >minn){ s=it->first; minn=it->second; //cout<<"Note2: "<<minn<<endl; } else if(it->second==minn && it->first<s){ s=it->first; } } if(minn) cout<<s<<":"<<minn<<endl;}int main(){ int cnt=0; int bj=0; int len=0; int star=0; int last_bj=0; string s_last,s_cur,s_com; while(getline(cin,s)){ // cout<<s<<endl; if(s=="####"){ Print(); mmat.clear(); continue; } cnt=0; last_bj=0; len=s.length(); //cout <<"len: "<<len<<endl; for(int i=0;i<len;i++){ if(s[i]==' '){ if(cnt==1){//s_cur:1~2 s_cur=s.substr(star,i-star); //cout<<"Note0: "<<s_cur<<" i:"<<i<<endl; cnt=2; if(last_bj==1){ s_com=s_last+" "+s_cur; mmat[s_com]++; //cout<<"Note: i: "<<i<<" "<<s_com<<" "<<mmat[s_com]<<endl; } s_last=s_cur; last_bj=1; } } else if(s[i]==','||s[i]=='.'){ if(cnt==1){ s_cur=s.substr(star,i-star); //if(s_cur==","||s_cur=="."){ //continue; //} cnt=2; if(last_bj==1){ s_com=s_last+" "+s_cur; mmat[s_com]++; //cout<<"Note: "<<s_com<<" "<<mmat[s_com]<<endl; } last_bj=0; } cnt=2; last_bj=0; } else{ if(cnt==0||cnt==2){ star=i; cnt=1; } } } if(s[len-1]!=' '){ s_cur=s.substr(star,len-star); cnt=2; if(last_bj==1){ s_com=s_last+" "+s_cur; mmat[s_com]++; //cout<<"Note: "<<s_com<<" "<<mmat[s_com]<<endl; } s_last=s_cur; last_bj=1; } } return 0;}// abc,.,.,. ,.,., ,.,.,abc abc ,,.,., abc abc abc,.,.,afe afe afe afe,.,
0 0
- Hiho 1385 模拟,细节
- hiho 1268 九宫 搜索 模拟
- hiho 1228 Mission Impossible 6(模拟)
- Uva 127 模拟+细节
- UVA10366(细节模拟)
- hiho#1054 : 滑动解锁 (hiho模拟面试题2 - google在线技术笔试模拟)
- hiho~
- Excellent Team(模拟,细节)
- hdu5237-字符串模拟&细节-Base64
- hiho 1228(Mission Impossible 6-模拟文本编辑器)
- hiho 1270 建造基地 dp 完全背包 模拟
- hiho 1271 舰队游戏 状压dp 贪心 模拟
- hihoCoder hiho一下 第148周--Font Size (模拟)
- hiho #1051 : 补提交卡 (hiho模拟面试题2 - google在线技术笔试模拟 贪心+枚举)
- 2014 hiho模拟面试题1 - google在线技术笔试模拟 矩形判断
- UVA 10366 - Faucet Flow(贪心+模拟细节)
- pat 1100 Mars Numbers (20)(细节模拟)
- UVA602 日期计算(2)+模拟+细节
- 2016.09.29 queue.h
- android 获取相册图片和使用相机照照片 并使用Android自带图片剪裁界面剪裁
- [LeetCode]70. Climbing Stairs
- 字符串转十六进制
- Linux下memset大内存时报错(地址越界)
- Hiho 1385 模拟,细节
- 归并排序递归及非递归实现(自然合并排序)
- HDU 2837Calculation
- RCNN--Fast-rcnn--Faster RCNN(思路整理)
- 移动端页面在苹果手机中需要主要的问题
- 项目问题汇总
- 利用通道以及递归方法拷贝文件的代码案例
- 【JavaScript】严格模式详解
- 源码推荐:17款抽奖源码下载,非常实用