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 |
没用排序,但是一直runtime Error,之前有人发帖说同样方法AC过,不知道原因#include <stdio.h> #include <stdlib.h> int main() { int data[10000000] = {0}; int n; int i = 0,j = 0,k=0; char s[32]; int m = 0; int p = 0; scanf("%d",&n); for(;i<n;i++) { scanf("%s",s); j = 0; k = 0; while(s[j] != '\0') { if(s[j] == '-') { j++; continue; } if(s[j]>='A' && s[j] <= 'P') { //m = m * 10 + (s[j] - 'A') / 3 + 2; s[k] = (s[j] - 'A') / 3 + '2'; } else if(s[j] > 'Q' && s[j] <= 'Y') { //m = m * 10 + (s[j] - 'Q') / 3 + 7; s[k] = (s[j] - 'Q') / 3 + '7'; } else s[k] = s[j]; j++; k++; } s[k] = '\0'; m = atoi(s); data[m] ++; } i = 0; j = 0; for(;i<10000000;i++) { if(data[i] > 1) { printf("%03d-%04d %d\n",i/10000,i%10000,data[i]); j = 1; } } if(j == 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