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 |
上帝啊,要崩溃了,各种error都出现了......# include<iostream.h> # include<string.h> # include <stdlib.h> int cmp(const void *arg1,const void*arg2 ) {return strcmp((char*) arg1, (char*) arg2);} void main() { char b,(*a)[8]; int *c; long int n; cin >>n; a=new char[n][8]; c=new int[n]; for(int i=0;i<n;i++) for(int j=0;j<7;j++) { cin >>b; if(b>='0'&&b<='9') a[i][j]=b; else if (b>='A'&&b<='C') a[i][j]='2'; else if(b>='D'&&b<='F') a[i][j]='3'; else if(b>='G'&&b<='I') a[i][j]='4'; else if(b>='J'&&b<='L') a[i][j]='5'; else if(b>='M'&&b<='O') a[i][j]='6'; else if(b=='P'||b=='R'||b=='S') a[i][j]='7'; else if(b>='T'&&b<='V') a[i][j]='8'; else if(b>='W'&&b<='Y') a[i][j]='9'; else j--; c[i]=1; } qsort(a,n,sizeof(a[0]),cmp); /* for(int x=0;x<n;x++) { for(int y=x+1;y<n;y++) { int d=1; for(int z=0;z<7;z++) { if(a[x][z]!=a[y][z]) {d=0;break;} } if(d==1) {c[x]+=1;a[y][0]='A'; } } }*/ for(char x1='0';x1<='9';x1++) for(int x3=0;x3<n;x3++) { if(a[x3][0]==x1) { for(int x2=x3+1;a[x2][0]<x1+1;x2++) { int d=1; for(int z=0;z<7;z++) { if(a[x3][z]!=a[x2][z]) {d=0;break;} } if(d==1) {c[x3]+=1;a[x2][0]='A'; } } } } for(int i3=0;i3<n;i3++) if(c[i3]>1&&a[i3][0]!='A') cout<<a[i3][0]<<a[i3][1]<<a[i3][2] <<"-"<<a[i3][3]<<a[i3][4]<<a[i3][5]<<a[i3][6] <<" "<<c[i3]<<endl; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator