POJ 1002 用map容器写的,自己运行对了,提交确实 wrong answer,怎么回事
来源:互联网 发布:mac safari广告净化器 编辑:程序博客网 时间:2024/04/29 06:54
#include <iostream>using namespace std;#include <string>#include <map>char AlphaToInteger(char ch);void printTelNum(string str);int main(){int n=0,i=0,j=0,len=0,ncount=1;cin>>n;string *str=new string[n];string::iterator str_it;map<string,int> strMapName;map<string,int>::iterator it;for (i=0;i<n;i++){cin>>str[i];for (str_it=str[i].begin();str_it != str[i].end();++str_it){if (*str_it=='-'){str[i].erase(str_it);// 删除最后一个字符——出错}if (str_it==str[i].end()){break;}}len=str[i].length();for (j=0;j<len;j++){if (str[i][j]>'9'){str[i][j]=AlphaToInteger((char)str[i][j]);}}if (strMapName.count(str[i])){it=strMapName.find(str[i]);it->second+=1;}else{strMapName.insert(map<string,int>::value_type(str[i],1));}}string temp;int flag=0;for (it=strMapName.begin();it != strMapName.end();it++){if (it->second>1){flag=1;temp=it->first;printTelNum(temp);cout<<" "<<it->second<<endl;}}if (flag==0){cout<<"No duplicates."<<endl;}return 0;}char AlphaToInteger(char ch){char temp;switch (ch){case 'A':case 'B':case 'C':temp='2';break;case 'D':case 'E':case 'F':temp='3';break;case 'G':case 'H':case 'I':temp='4';break;case 'J':case 'K':case 'L':temp='5';break;case 'M':case 'N':case 'O':temp='6';break;case 'P':case 'R':case 'S':temp='7';break;case 'T':case 'U':case 'V':temp='8';break;case 'W':case 'X':case 'Y':temp='9';break;}return temp;}void printTelNum(string str){int i=0,len=0;len=str.length();for (i=0;i<len;i++){cout<<str[i];if (i==2){cout<<'-';}}}
0 0
- POJ 1002 用map容器写的,自己运行对了,提交确实 wrong answer,怎么回事
- poj 1035(Wrong Answer)
- 关于UVa Online Judge提交总是Wrong answer的问题
- 请教!!!POJ: 1007一直wrong answer,换一种写法就AC,其实是一样的。。
- 你们猜对了:12306确实是让淘宝做的
- 提交自己写的Topology
- 自己写的简易map
- 用eclipse写html的时候出现红杠怎么回事
- wrong answer 原因
- poj1001 Wrong Answer
- 抉择的路上自己走对了吗
- Java 单例真的写对了么?
- Java 单例真的写对了么?
- Java 单例真的写对了么?
- poj 2503 map容器
- Set改写成Map使用,自己写的一个Map
- wrong answer of URAL 1802
- Wrong answer of URAL 1807
- Adaptive Support Weight Approach for Correspondence Search
- Java设计模式----策略模式
- 使用jsonp有数据返回,但是success不执行的解决办法
- ora-00054:resource busy and acquire with nowait specified解决方法
- 使用NDK编译的时候出现 undefined reference to
- POJ 1002 用map容器写的,自己运行对了,提交确实 wrong answer,怎么回事
- ExtJS4 按条件查询的方法
- 九大视频接口
- Android自定义属性,format详解
- IOS开发经常使用的开源框架和类
- C++ 二分法查找操作 算法(4)
- 赵雅智_android多线程下载带进度条
- Notification 安卓 通知的创建
- oracle 11g导出遇到的问题总结