Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
注意输出。。。分享一下my STL// 4873279.cpp : Defines the entry point for the console application. // //#pragma warning(disable:C4786) //#include "stdafx.h" #include<map> #include<iostream> #include<string> #include<fstream> using namespace std; int main(int argc, char* argv[]) { //ifstream cin("aaa.txt"); map<char,char>m; int i,j; m['A']='2'; m['B']='2'; m['C']='2'; m['D']='3'; m['E']='3'; m['F']='3'; m['G']='4'; m['H']='4'; m['I']='4'; m['J']='5'; m['K']='5'; m['L']='5'; m['M']='6'; m['N']='6'; m['O']='6'; m['P']='7'; m['R']='7'; m['S']='7'; m['T']='8'; m['U']='8'; m['V']='8'; m['W']='9'; m['X']='9'; m['Y']='9'; for(i=0;i<=9;i++) m['0'+i]='0'+i; int n; cin>>n; string s; map<string,int>result; while(cin>>s) { string ss=""; j=0; for(i=0;i<s.length();i++) { if(s[i]!='-')ss+=m[s[i]]; } string::iterator its=ss.begin(); ss.insert(its+3,'-'); map<string,int>::iterator it; it=result.find(ss); int count=0; if(it!=result.end()) { result[ss]+=1; } else result[ss]=1; // cout<<ss<<endl; } map<string,int>::iterator itt; int c=0; for(itt=result.begin();itt!=result.end();itt++) { if((*itt).second>1) {c=1; cout<<(*itt).first<<" "<<(*itt).second<<endl;} } if(c==0)cout<<"No duplicates."<<endl;//这里的No duplicates要加.不然就错了,,可是奇怪的是为什么不是presentation error呢? return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator