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 |
高手帮忙看看为何wa!!!!!郁闷中#include<stdio.h> #include<string.h> #include<stdlib.h> #include<ctype.h> #define Max 100000 int turn[26] = {2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9}; long date[Max],c,n; char s[200],str[20]; long covert() //转换成标准形式// { int i,t; long k; k = 0; for (i = 0;i < strlen(s);i++) { if (s[i] >= '0' && s[i] <= '9') { t = s[i] - '0'; k = k * 10 + t; } else if (isupper(s[i])) { t = turn[s[i] - 'A']; k = k * 10 + t; } } return k; } void quicksort(long i,long t) //快排// { long j,k,x; j = i; k = t; x = date[(i + t) / 2]; do { while (date[j] < x) j++; while (date[k] > x) k--; if (j <= k) { c = date[j]; date[j] = date[k]; date[k] = c; j++; k--; } } while (j <= k); if (i < k) quicksort(i,k); if (j < t) quicksort(j,t); } void doit() { long i,k,c;//c纪录相同号码出现次数// int t,get; quicksort(0,n - 1); c = 1; date[n] = -1; get = 0; for (i = 0;i < n;i++) { if (date[i] == date[i + 1]) c++; else { if (c != 1) { ltoa(date[i],str,10);//转成字符串输出// while (strlen(str) < 7) { for (t = strlen(str);t > 0;t--)//补‘0’// str[t] = str[t - 1]; str[0] = '0'; } for (t = 0;t <= 6;t++) { printf("%c",str[t]); if (t == 2) printf("-"); } printf(" %ld\n",c); get = 1; } c = 1; } } if (!get) printf("No duplicates.\n"); } void init() { long i; scanf("%ld",&n); for (i = 0;i < n;i++) { scanf("%s",&s); date[i] = covert(); } } void main() {init(); doit();} Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator