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 |
总是Output Limit Exceeded麻烦大神帮忙看看什么问题#include <stdio.h> #include <stdlib.h> int c2n(char c) { switch (c) { case 'A': case'B': case 'C': return 2; break; case 'D': case'E': case 'F': return 3; break; case 'G': case'H': case 'I': return 4; break; case 'J': case'K': case 'L': return 5; break; case 'M': case'N': case 'O': return 6; break; case 'P': case'R': case 'S': return 7; break; case 'U': case'V': case 'T': return 8; break; case 'W': case'X': case 'Y': return 9; break; } } int cmp(const void * a , const void * b) { return *(int*)a-*(int*)b; } int main() { int n,i,ii,d[10000]; int iiii; char a[100]; //freopen("1002.txt","r",stdin); i=0; ii=0; scanf("%d",&n); while(scanf("%s\n",&a)!=EOF ) { if (i==n) break; ii=0; iiii=0;//iiii count 7 times and ii record the position of a d[i]=0; while(iiii<7) { if (a[ii]=='-') { ii++; continue;//attention! } else if (a[ii]<='Z'&&a[ii]>='A') { d[i]=d[i]*10+c2n(a[ii]); ii++; iiii++; } else if (a[ii]<='9'&&a[ii]>='0') { d[i]=d[i]*10+a[ii]-'0'; ii++; iiii++; } else { printf("input wrong\n"); } } i++; } qsort(d,n,sizeof(int),cmp); int cont=0; int flag=0; i=0; while(i<n) { cont=0; if (d[i]==d[i+1]) { cont=2; i++; flag =1; while(d[i]==d[i+1]) { cont++; i++; } printf("%03d-%04d %d\n",d[i]/10000,d[i]%10000,cont); } i++; } if (flag==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