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 |
我在VC6.0通过了,为什么在这里Runtime error (思路简捷,程序简单)这里假设测试数据最多15个,而不是100000个. 这个程序非常简单,根本没用上C语言的高级用法,为什么会Runtime error 呢? 回复请至469901093@qq.com 欢迎指教 我系东北师大 大一新生 #include<stdio.h> #include<string.h> char change(char c); int main() { char c,a[15][20],b[15][8],sort[15][8],temp[8]; int n,i,j,k,mark,temporary,rc[15],flag[15]={0}; scanf("%d",&n); for(i=0;i<=n-1;i++) { scanf("%s",&a[i]); } for(i=0;i<=n-1;i++) { j=0; k=0; while(a[i][j]!='\0') { c=a[i][j]; if(c!='-') { b[i][k]=change(c); k=k+1; } j=j+1; } b[i][k]='\0'; } mark=0; for(i=0;i<=14;i++) { rc[i]=1; } k=0; for(i=0;i<=n-2;i++) { if(flag[i]!=1) { for(j=i+1;j<=n-1;j++) { if((flag[j]!=1)&&(strcmp(b[i],b[j])==0)) { mark=1; flag[j]=1; rc[k]=rc[k]+1; } } } if(rc[k]>1) { strcpy(sort[k],b[i]); k=k+1; } } if(mark==0) { printf("No duplicates.\n"); } else { for(i=1;i<=k-1;i++) { for(j=0;j<=k-i-1;j++) { if(strcmp(sort[j],sort[j+1])>0) { strcpy(temp,sort[j]); strcpy(sort[j],sort[j+1]); strcpy(sort[j+1],temp); temporary=rc[j]; rc[j]=rc[j+1]; rc[j+1]=temporary; } } } for(i=0;i<=k-1;i++) { for(j=0;j<=2;j++) { printf("%c",sort[i][j]); } printf("-"); for(j=3;j<=6;j++) { printf("%c",sort[i][j]); } printf(" %d\n",rc[i]); } } return 0; } char change(char c) { switch(c) { case 'A': case 'B': case 'C':c='2';break; case 'D': case 'E': case 'F':c='3';break; case 'G': case 'H': case 'I':c='4';break; case 'J': case 'K': case 'L':c='5';break; case 'M': case 'N': case 'O':c='6';break; case 'P': case 'R': case 'S':c='7';break; case 'T': case 'U': case 'V':c='8';break; case 'W': case 'X': case 'Y':c='9';break; default :break; } return c; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator