Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:注意输出。。。分享一下my STL

Posted by qiaofangjie at 2009-05-06 19:16:45 on Problem 1002
In Reply To:注意输出。。。分享一下my STL Posted by:TangMing at 2009-04-22 00:56:52
> // 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator