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,那位高手指点一下#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) {int n,i,j,k,m=0,a,b=1; char ch; int q=0; //printf("please input the no:\n"); scanf("%d",&n); char s[n+1][15]; int p[n][7],t[n],sign[n]; for(i=0;i<n+1;i++) {k=0; gets(s[i]); } for(i=1;i<n+1;i++) { k=0; for(j=0;s[i][j]!='\0';j++) {if(s[i][j]=='A'||s[i][j]=='B'||s[i][j]=='C'||s[i][j]=='2') p[i-1][k++]=2; else if(s[i][j]=='D'||s[i][j]=='E'||s[i][j]=='F'||s[i][j]=='3') p[i-1][k++]=3; else if(s[i][j]=='G'||s[i][j]=='H'||s[i][j]=='I'||s[i][j]=='4') p[i-1][k++]=4; else if(s[i][j]=='J'||s[i][j]=='K'||s[i][j]=='L'||s[i][j]=='5') p[i-1][k++]=5; else if(s[i][j]=='M'||s[i][j]=='N'||s[i][j]=='O'||s[i][j]=='6') p[i-1][k++]=6; else if(s[i][j]=='P'||s[i][j]=='R'||s[i][j]=='S'||s[i][j]=='7') p[i-1][k++]=7; else if(s[i][j]=='T'||s[i][j]=='U'||s[i][j]=='V'||s[i][j]=='8') p[i-1][k++]=8; else if(s[i][j]=='W'||s[i][j]=='X'||s[i][j]=='Y'||s[i][j]=='9') p[i-1][k++]=9; else if(s[i][j]=='0') p[i-1][k++]=0; else if(s[i][j]=='1') p[i-1][k++]=1; else continue; } } for(i=0;i<n-1;i++) {j=i; for(k=i+1;k<n;k++) if((p[i][0]*1000000+p[i][1]*100000+p[i][2]*10000 +p[i][3]*1000+p[i][4]*100+p[i][5]*10+p[i][6])>(p[k][0]*1000000+p[k][1]*100000 +p[k][2]*10000+p[k][3]*1000+p[k][4]*100+p[k][5]*10+p[k][6])) j=k; if(j!=i) { for(a=0;a<7;a++) {b=p[i][a];p[i][a]=p[j][a];p[j][a]=b;} } } //printf("--------------------\n"); for(i=0;i<n;i++) sign[i]=0; for(i=0;i<n;i++) { b=1; if(sign[i]==0) { sign[i]=1; for(j=i+1;j<n;j++) if(sign[j]==0) {if((p[i][0]*1000000+p[i][1]*100000+p[i][2]*10000 +p[i][3]*1000+p[i][4]*100+p[i][5]*10+p[i][6])==(p[j][0]*1000000+p[j][1]*100000 +p[j][2]*10000+p[j][3]*1000+p[j][4]*100+p[j][5]*10+p[j][6])) {b++;sign[j]=1;} } } if(b>=2) {q++; for(k=0;k<3;k++) printf("%d",p[i][k]); printf("-"); for(k=3;k<7;k++) printf("%d",p[i][k]); printf(" %d",b); printf("\n"); } } if(q==0) printf("NO duplicates.\n"); system("PAUSE"); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator