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

map AC代码!

Posted by liuchen8899 at 2015-06-30 19:26:24 on Problem 2550
#include<cstdio>
#include<iostream>
#include<string>
#include<sstream>
#include<cstring>
#include<map>
using namespace std;
int main()
{
    string s,buf;
    int i,f,n,num=0;
    while(cin>>n)
    {
        f=0;
        map<string,int>mp;
        while (cin>>s&&s!="EndOfText")
        {
             for(i=0;i<s.length();i++)
             {
                  if (isalpha(s[i]))
                  {
                      s[i]=tolower(s[i]);
                  }
                  else
                  {
                      s[i]=' ';
                  }
             }
              stringstream ss(s);
              while (ss>>buf)
              {
                  mp[buf]++;
              }
        }
        if(num!=0)
        {
            cout<<endl;
        }
        for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
        {
            if(it->second==n)
            {
                cout<<it->first<<endl;
                f=1;
            }
        }
        if(f==0)
        {
            cout<<"There is no such word."<<endl;
        }
        num++;
    }
}

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