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 |
同样一段代码,不同OJ有的就AC了,有的就RE,大牛帮忙看看#include<iostream> #include<cstring> #include<ctype.h> #include<stdlib.h> using namespace std; char a[2000][2000]; int state[2000]; char juage(char a) { switch(a) { case 'A':case 'a':case 'B':case 'b':case 'C':case 'c': return '2'; case 'D':case 'd':case 'E':case 'e':case 'F':case 'f': return '3'; case 'G':case 'g':case 'H':case 'h':case 'I':case 'i': return '4'; case 'J':case 'j':case 'K':case 'k':case 'L':case 'l': return '5'; case 'M':case 'm':case 'N':case 'n':case 'O':case 'o': return '6'; case 'P':case 'p':case 'R':case 'r':case 'S':case 's': return '7'; case 'T':case 't':case 'U':case 'u':case 'V':case 'v': return '8'; case 'W':case 'w':case 'X':case 'x':case 'Y':case 'y': return '9'; } } void outthis(int u) { int t; for(t = 0 ; t < 3; t++) cout << a[u][t]; cout <<'-'; for(; t < 7; t++) cout << a[u][t]; cout << ' '; cout <<state[u]<< endl; } int main() { int num , temp , n , u , d , flag = 0 , i = 1; memset(state , 0 , sizeof(int) * 2000); cin >> num; char s[2000] , p[1000]; for(temp = 0 , n =0 ; temp < num; temp ++) { cin >> s; int t = strlen(s); for(d = 0 , u = 0 ; d < t; d ++) { if(isdigit(s[d])) p[u++] = s[d]; else if(isalpha(s[d])) p[u++] = juage(s[d]); } p[u] = '\0'; for(u =0 , i = 1; u < n; u++) { if(strcmp(a[u] , p) > 0) { for(int l = n + 1; l > u; l--) { strcpy(a[l] , a[l - 1]); state[l] = state[l - 1]; } strcpy(a[u], p); state[u] = 1; n++; i = 0; break; } else if(!strcmp(a[u] , p)) { flag = 1; state[u] ++; i = 0; break; } } if(n ==0) { n++; strcpy(a[0], p); state[0]++; } if(u == n && i) { strcpy(a[u] , p); state[u] ++; n++; } } if(flag) { for(u = 0; u < num; u++) { if(state[u] > 1) outthis(u); } } else cout << "No duplicates." << endl; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator