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

G++会WA,C++可过--map水题

Posted by GSWS at 2017-06-06 00:29:23 on Problem 1002
// #include <bits/stdc++.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
	map<char,char>ci;
	map<string,int>si;
	ci['A']=ci['B']=ci['C']='2';
	ci['D']=ci['E']=ci['F']='3';
	ci['G']=ci['H']=ci['I']='4';
	ci['J']=ci['K']=ci['L']='5';
	ci['M']=ci['N']=ci['O']='6';
	ci['P']=ci['R']=ci['S']='7';
	ci['T']=ci['U']=ci['V']='8';
	ci['W']=ci['X']=ci['Y']='9';
	int T;
	string s;
	scanf("%d",&T);
	while(T--){
		cin>>s;
		string str;
		for(int i=0;i<s.length();i++){
			if(isdigit(s[i])){
				str+=s[i];
			}
			else if(isalpha(s[i])){
				str+=ci[s[i]];
			}
		}
		si[str]++;
	}
	map<string,int>::iterator iter=si.begin();
	int flag=0;
	for(;iter!=si.end();iter++){
		if(iter->second>1){
			flag=1;
			for(int i=0;i<7;i++){
				printf("%c",iter->first[i]);
				if(i==2) printf("-");
			}
			printf(" %d\n",iter->second);
		}
	}
	if(!flag){
		printf("No duplicates.\n");
	}
	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