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 |
请各位快来帮我看看呀, 哪里错了#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; long num[100005]={0}; long tran(char chr[]) { int len, i, n=0; len=strlen(chr); for (i=0; i<len; i++) switch (chr[i]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': n=n*10+(int)chr[i]-48; break; case 'A': case 'B': case 'C': n=n*10+2; break; case 'D': case 'E': case 'F': n=n*10+3; break; case 'G': case 'H': case 'I': n=n*10+4; break; case 'J': case 'K': case 'L': n=n*10+5; break; case 'M': case 'N': case 'O': n=n*10+6; break; case 'P': case 'R': case 'S': n=n*10+7; break; case 'T': case 'U': case 'V': n=n*10+8; break; case 'W': case 'X': case 'Y': n=n*10+9; break; } return n; } void W(long l) { long i, j, s=1; bool f=true; for (i=0; i<l; i++) { if (num[i]==num[i+1]) s++; else { if (s!=1) { printf("%03d-%04d %d\n", (int)(num[i]/10000), (int)(num[i]%10000), s); s=1; f=false; } } } if (f) printf("No duplicates.\n"); return; } int main() { long N, i; char chr[20]; scanf("%ld", &N); for (i=0; i<N; i++) { scanf("%s", chr); num[i]=tran(chr); } sort( num, num+i ); W(i); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator