c - WA in CPRMT(common permutation) -
#include<stdio.h> void compare(char a[], char b[]); void sort(char a[], char b[], char c[], int k); int main() { char a[1001], b[1001]; while((scanf("%s%s", a,b))!=eof) { compare(a, b); } return 0; } void compare(char a[], char b[]) { int i,j,k,l,m; i=0;k=0;j=0; char c[1001]; while(a[i]!='\0') { while(b[j]!='\0') { l=a[i]; m=b[j]; if(l==m) { c[k]=a[i]; k++; } j++; } i++; j=0; } c[k]='\0'; sort(a,b,c,k); } void sort(char a[], char b[], char c[], int k) { int i,m,n,j,o,p,h,l[k]; for(i=0;i<=k;i++) { l[i]=c[i]; } for(i=0;i<k;i++) { for(j=0;j<k-1;j++) { if(l[j]>l[j+1]) { m=l[j]; l[j]=l[j+1]; l[j+1]=m; c[j]=l[j]; c[j+1]=l[j+1]; } } } i=0; while(l[i+1]!='\0') { if(l[i]==l[i+1]) { m=0; n=0; j=0; while(a[j]!='\0') { if(a[j]==l[i]) { m=m+1; } j++; } j=0; while(b[j]!='\0') { if(b[j]==l[i]) { n=n+1; } j++; } if(m<=n) { h=m; } else { h=n; } o=m*n; p=0; while(c[i+p+h]!='\0') { c[i+p+h]=c[i+p+o]; l[i+p+h]=l[i+p+o]; p++; } } i++; } printf("%s\n", c); } i still getting wa question...can sugggest me more test cases.... have tried following test cases input pretty women walking down street test totter
and output is- e nw et ett
i think skipping test cases........if know more test cases please let me know..
Comments
Post a Comment