zoukankan      html  css  js  c++  java
  • 我的北大ACM POJ 1002题解

    北大acm POJ1002题解c++语言

    最近才开始,惭愧啊,这个题花了我好久。

    Source Code

    Problem: 1002 User: absolute
    Memory: 5204K Time: 922MS
    Language: C++ Result: Accepted

    • Source Code
      #include <iostream>
      #include <map>
      #include <string>
      using namespace std;
      char change[] = {'2','2','2','3','3','3','4','4','4',
      '5','5','5','6','6','6','7','Q','7','7','8','8','8','9','9','9','Z'};
      
      int main()
      {
      	map<string,int> resultset;
      	map<string,int>::iterator iter;
      	int line;
      	scanf("%d",&line);
      	int i;
      	for(i=0;i<line;i++)
      	{
      		char temp[100];
      		scanf("%s",temp);
      		char afterchange[9];
      		int j=0,k=0;
      		int length = strlen(temp);
      		while(j<length)
      		{
      			if(k==3)
      			{
      				afterchange[k++]='-';
      			}
      			else if(temp[j]<'Z'&&temp[j]>='A')
      			{
      				afterchange[k++]=change[temp[j++]-'A'];
      			}
      			else if(temp[j]=='-')
      			{
      				j++;
      			}
      			else
      			{
      				afterchange[k++]=temp[j++];
      			}
      
      		}
      		afterchange[k]='\0';
      		++resultset[afterchange];
      	}
      	bool flag = false;
      	map<string,int>::iterator end = resultset.end();
      	for(iter = resultset.begin(); iter != end; ++iter)
      	{
      		if(iter->second>1)
      		{
      			flag = true;
      			cout<<iter->first<<" "<<iter->second<<endl;
      		}
      	}
      	if(flag==false)
      		cout<<"No duplicates."<<endl;
      	return 0;
      }
  • 相关阅读:
    2014第16周六
    2014第16周五
    2014第16周四
    2014第16周三CSS布局再学习摘录
    2014第16周二
    2014第16周一
    2014第15周日
    2014第15周六
    2014第15周五
    SDN:软件定义网络
  • 原文地址:https://www.cnblogs.com/absolute8511/p/1649601.html
Copyright © 2011-2022 走看看