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上能运行,结果一样,但是狂RE,各位大虾帮忙看看,我才大一,新手,想了很久了#include "stdio.h" #include "string.h" main() {int n,x[100]={1},y=0,i,j,t,r,z[100]={0}; char a[100][100],b[100][8],s[100]; scanf("%d",&n); for(i=0;i<n;i++) scanf("%s",&a[i]); for(i=0;i<n;i++) /*将'-'去掉,搞成一连没有间隔的字符*/ for(j=0;a[i][j]!='\0';j++) {if(a[i][j]=='-'&&a[i][j+1]=='-') {for(t=j;(a[i][t+2])!='\0';t++) a[i][t]=a[i][t+2];} if(a[i][j]=='-') {for(t=j;(a[i][t+1])!='\0';t++) a[i][t]=a[i][t+1]; } } for(i=0;i<n;i++){a[i][7]='\0';} /*在最后加上结束符*/ for(i=0;i<n;i++) {for(j=0;j<8;j++) { if(a[i][j]=='A'||a[i][j]=='B'||a[i][j]=='C') b[i][j]='2'; else if(a[i][j]=='D'||a[i][j]=='E'||a[i][j]=='F') b[i][j]='3'; else if(a[i][j]=='G'||a[i][j]=='H'||a[i][j]=='I') b[i][j]='4'; else if(a[i][j]=='J'||a[i][j]=='K'||a[i][j]=='L') b[i][j]='5'; else if(a[i][j]=='M'||a[i][j]=='N'||a[i][j]=='O') b[i][j]='6'; else if(a[i][j]=='P'||a[i][j]=='R'||a[i][j]=='S') b[i][j]='7'; else if(a[i][j]=='T'||a[i][j]=='U'||a[i][j]=='V') b[i][j]='8'; else if(a[i][j]=='W'||a[i][j]=='X'||a[i][j]=='Y') b[i][j]='9'; else b[i][j]=a[i][j]; }} for(i=0;i<n-1;i++) /*排序*/ for(j=i+1;j<n;j++) {if(b[i][0]>b[j][0]) {strcpy(s,b[i]); strcpy(b[i],b[j]); strcpy(b[j],s);}} for(i=1;i<n;i++) /*如果某一行是前面出现过的,则z[i]=1*/ for(t=0;t<i;t++) if(strcmp(b[t],b[i])==0) {z[i]=1;} for(i=0;i<n;i++) /*如果某一行,这一行的z[i]=0,即前面没出现过,就计算它后面有多少个一样的*/ if(z[i]==0) {for(j=i+1;j<n;j++) {if(strcmp(b[i],b[j])==0) x[i]++;} } for(i=1;i<n;i++) x[i]++; for(t=0;t<n;t++) {if(x[t]>1) {printf("%c%c%c-%c%c%c%c %d\n",b[t][0],b[t][1],b[t][2],b[t][3],b[t][4],b[t][5],b[t][6],x[t]); y=1;}} if(y!=1) printf("No duplicates.\n"); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator