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

有什么要特别注意的地方吗?总是WA....

Posted by jjfall at 2007-08-04 13:44:29 on Problem 1002
#include<iostream> 
#include<vector>
#include<string>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<string> total;
    for(int i=0;i<n;i++)
    {
          string temp;
          char num[7];
          cin>>temp;
          int k=0;
          for(int j=0;j<temp.size();j++)
          {
                  if(temp[j]>='0' && temp[j]<='9') num[k++]=temp[j];
                  else if(temp[j]>='A' && temp[j]<'Q') num[k++]=(temp[j]-'A')/3+2+'0';
                  else if(temp[j]>'Q' && temp[j]<='Y')  num[k++]=(temp[j]-'A'-1)/3+2+'0';    
                  else continue;           
          }
          string a(num,3);
          a+='-';
          string b(num+3,num+7);
          a+=b;
          total.push_back(a);
    }
    sort(total.begin(),total.end());
    for(int q=0;q<n;q++) cout<<total[q]<<endl;
    int r=1,m=0;
    while(r<=n)
    {
              if(r<n&&total[r]==total[r-1])
              {
                   ++r;
                   ++m;
                   continue;                                  
              }
              else if(m>0) cout<<total[r-1]<<" "<<m+1<<endl;
              m=0;
              ++r;
    }
    system("pause");
    
} 

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