| ||||||||||
| 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 | |||||||||
Re:我做两天了总是WA,谁帮我看看啊In Reply To:我做两天了总是WA,谁帮我看看啊 Posted by:zhzm883 at 2006-08-13 00:31:46 > #include"stdio.h"
> #include"string.h"
> #include <stdlib.h>
> #define N 1000002
> char b[100000][100], a[100000][100],ji=0;
> merge(char a1[][100], int a1_s, char a2[][100], int a2_s, int a2_e,
> char a3[][100], int a3_s, int a3_e)
> {
> int i, j, k=0, h;
> i=a2_s;
> j=a3_s;
> while(i<=a2_e&&j<=a3_e)
> {
> if(strcmp(a2[i],a3[j])<0)
> strcpy(b[k++],a2[i++]);
> else
> strcpy(b[k++],a3[j++]);
> }
> while(i<=a2_e) strcpy(b[k++],a2[i++]);
> while(j<=a3_e) strcpy(b[k++],a3[j++]);
> for(h=0;h<k;h++)
> strcpy(a1[a1_s+h],b[h]);
> }
> sort(char a[][100] ,int left,int right)
> {
> int half;
> if(left<right)
> {
> half=(left+right)/2;
> sort(a,left,half);
> sort(a,half+1,right);
> merge(a,left,a,left,half,a,half+1,right);
> }
> }
> main()
> {
> int n, i, j, p,q;
> char ch, c[20], k, w=0;
> int b[100000]={0};
> scanf("%d",&n);
> ch=getchar();
> for(i=0;i<n;i++)
> gets(a[i]);
> for(i=0;i<n;i++)
> {
> for(j=0;a[i][j]!='\0';j++)
> {
> if(a[i][j]=='A'||a[i][j]=='B'||a[i][j]=='C')
> a[i][j]='2';
> else if(a[i][j]=='D'||a[i][j]=='E'||a[i][j]=='F')
> a[i][j]='3';
> else if(a[i][j]=='G'||a[i][j]=='H'||a[i][j]=='I')
> a[i][j]='4';
> else if(a[i][j]=='J'||a[i][j]=='K'||a[i][j]=='L')
> a[i][j]='5';
> else if(a[i][j]=='M'||a[i][j]=='N'||a[i][j]=='O')
> a[i][j]='6';
> else if(a[i][j]=='P'||a[i][j]=='R'||a[i][j]=='S')
> a[i][j]='7';
> else if(a[i][j]=='T'||a[i][j]=='U'||a[i][j]=='V')
> a[i][j]='8';
> else if(a[i][j]=='W'||a[i][j]=='X'||a[i][j]=='Y')
> a[i][j]='9';
> else if(a[i][j]=='-')
> {
> for(k=j;a[i][k]!='\0';k++)
> a[i][k]=a[i][k+1];
> j--;
> }
>
> }
> }
> sort(a,0,n-1);
> for(p=0;p<n;p++)
> {
>
> if(strcmp(a[p],a[p+1])==0)
> {
> b[ji]++;
> w=1;
> }
> if(strcmp(a[p],a[p+1])!=0&&b[ji]!=0)
> {
>
>
> if(a[p][0]!=0)
> { for(j=0;j<3;j++)
> printf("%c",a[p][j]);
> printf("-");
> for(;a[p][j]!='\0';j++)
> printf("%c",a[p][j]);
> printf(" %d\n",b[ji]+1);
> }
> ji++;
>
>
> }
>
> }
> if(w==0)
> 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