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 |
几组神数据全过了 数组大小200 依然WA,急求帮忙啊~~~#include <stdio.h> #include <stdlib.h> #include <string.h> #define LENGTH 200 int cmp(const void *a,const void *b) { return strcmp((char *)a,(char *)b); } int main() { int numbers=0; int i; scanf("%d",&numbers); char array_con[100000][9]; char a[LENGTH]; char map[]="22233344455566677778889999"; for( i=0;i<numbers;i++) { int j=0,ind=0; scanf("%s",&a); while(a[j]!='\0') { if('-'==a[j]){j++;} else if(a[j]>='A'&&a[j]<='Z') { array_con[i][ind]=map[a[j]-'A']; j++;ind++; } else if(a[j]>='0'&&a[j]<='9') { array_con[i][ind]=a[j]; j++;ind++; } if(3==ind) { array_con[i][ind]='-'; ind++; } } array_con[i][8] = '\0'; } strcpy(array_con[numbers],"aaa-aaaa"); qsort(array_con,numbers,sizeof(array_con[0]),cmp); int turble=1;int g_turble=0; for( i=0;i<numbers;i++) { if( 0==strcmp(array_con[i],array_con[i+1]) ) {turble++;g_turble++;} else if(turble>1) { printf("%s",array_con[i]); printf(" %d\n",turble); turble=1; } } if(0==g_turble) 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