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; int cmp(int a,int b) { return a < b; } int Plus(int n) { int i; int val = 1; for (i = 0;i < n;i ++) { val = val * 10; } return val; } int main() { int i,n,j,m,sum,k,l,flag; char strings[20]; int num[100000]; scanf("%d",&n); memset(num,0,sizeof(num)); flag = 0; for (j = 0;j < n;j ++) { scanf("%s",strings); num[j] = 0; for (i = 0;strings[i] != '\0';i ++) { m = -1; if((strings[i] >= '0') && (strings[i] <= '9')) { m = strings[i] - '0'; } else if ((strings[i] == 'A') || (strings[i] == 'B') || (strings[i] == 'C')) { m = 2; } else if ((strings[i] == 'D') || (strings[i] == 'E') || (strings[i] == 'F')) { m = 3; } else if ((strings[i] == 'G') || (strings[i] == 'H') || (strings[i] == 'I')) { m = 4; } else if ((strings[i] == 'J') || (strings[i] == 'K') || (strings[i] == 'L')) { m = 5; } else if ((strings[i] == 'M') || (strings[i] == 'N') || (strings[i] == 'O')) { m = 6; } else if ((strings[i] == 'P') || (strings[i] == 'R') || (strings[i] == 'S')) { m = 7; } else if ((strings[i] == 'T') || (strings[i] == 'U') || (strings[i] == 'V')) { m = 8; } else if ((strings[i] == 'W') || (strings[i] == 'X') || (strings[i] == 'Y')) { m = 9; } if (m != -1) { num[j] = num[j] * 10 + m; } } } sort(num,num + n,cmp); for (i = 0;i < n;i ++) { sum = 1; l = 6; for (j = i + 1;j < n;j ++) { if (num[i] == num[j]) { sum++; } else { break; } } if (sum > 1) { flag = 1; for (k = 0;k < 3;k ++) { printf("%d",num[i] / Plus(l)); num[i] = num[i] % Plus(l); l--; } printf("-"); for (k = 3;k < 7;k ++) { printf("%d",num[i] / Plus(l)); num[i] = num[i] % Plus(l); l--; } printf(" %d\n",sum); } i = j - 1; } if (flag == 0) { printf("\nNo 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