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<stdlib.h> //排序 int Compare(const void *elem1, const void *elem2) { return *((int *)(elem1)) - *((int *)(elem2)); } int main() { int count, temp, i, j, n, number, flag = 0; int array[100001]; char str[500]; for(i = 0; i <= 100000; i++) array[i] = -1; scanf("%d", &count); //处理数据,全部转为整形 for(i = 0; i < count; i++) { array[i] = 0; temp = 1000000; scanf("%s", str); for(j = 0; str[j] != NULL;j++) { if(str[j] != '-' && str[j] != 'Q' && str[j] != 'Z') { if(str[j] == '1') array[i] += 1 * temp; if(str[j] == 'A' || str[j] == 'B' || str[j] == 'C' || str[j] == '2') array[i] += 2 * temp; if(str[j] == 'D' || str[j] == 'E' || str[j] == 'F' || str[j] == '3') array[i] += 3 * temp; if(str[j] == 'G' || str[j] == 'H' || str[j] == 'I' || str[j] == '4') array[i] += 4 * temp; if(str[j] == 'J' || str[j] == 'K' || str[j] == 'L' || str[j] == '5') array[i] += 5 * temp; if(str[j] == 'M' || str[j] == 'N' || str[j] == 'O' || str[j] == '6') array[i] += 6 * temp; if(str[j] == 'P' || str[j] == 'R' || str[j] == 'S' || str[j] == '7') array[i] += 7 * temp; if(str[j] == 'T' || str[j] == 'U' || str[j] == 'V' || str[j] == '8') array[i] += 8 * temp; if(str[j] == 'W' || str[j] == 'X' || str[j] == 'Y' || str[j] == '9') array[i] += 9 * temp; temp /= 10;//从高位到地位,每次位权都要减小 } } } //排序 qsort(array, count, sizeof(int), Compare); //输出 number = array[0]; n = 0; for(i = 0; i <= count; i++) { if(number != array[i]) { if(n > 1) { if(array[i - 1] % 10000 == 0 && array[i - 1] / 10000 == 0) printf("000-0000 %d\n",n); else if(array[i - 1] % 10000 == 0) printf("%3d-0000 %d\n", array[i - 1] / 10000, n); else if(array[i - 1] / 10000 == 0) printf("000-%4d %d\n", array[i - 1] % 10000, n); else printf("%3d-%4d %d\n",array[i - 1] / 10000, array[i - 1] % 10000, n); flag = 1; } n = 1; number = array[i]; } else { n++; } } //如果没有,输出No duplicates. 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