Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
初来乍到,哪位大牛看一下,本机下常,为啥是CE#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator