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

初来乍到,哪位大牛看一下,本机下常,为啥是CE

Posted by neu_dtbest at 2007-08-08 19:11:52 on Problem 1002
#include<iostream>

#define N 100000
using namespace std;

int main()
 {
   int a[]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,0,7,7,8,8,8,9,9,9,0};
   int num;
   long tel[N],i,n,flag=0;
   char ch;
   long temp;
   scanf("%ld",&n);
   getchar();
  
   for(i=0;i<n;i++)
   {
     temp=0;
     while((ch=getchar())!='\n')
      {
 	    if(ch>='A'&&ch<='Z') temp=temp*10+a[ch-65];
 	       else if(ch>='0'&&ch<='9') temp=temp*10+ch-48;
      }
        tel[i] = temp;
    }
    sort(tel,tel+n);
    
    temp =0;
    for(i=1;i<n;i++)
    {
       if(tel[i]==tel[i-1])
          {  
             if(!flag)
             {    
                  temp = tel[i];
                  num = 1;
                  flag=1;
             }
             if(tel[i]==temp)
               num++;
          }
       else if(flag)
       {
            printf("%03d-%04d %ld\n",(int)temp/10000,(int)temp%10000,num);
            flag=0;
       }
    }
   if(flag)
      printf("%03d-%04d %ld\n",(int)temp/10000,(int)temp%10000,num);
   if(temp==0) 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