#include<stdio.h>
#include<conio.h>
main()
{
FILE *f=fopen("slinput.txt","r");
char a[20],b[20],c[40];
fscanf(f,"%s",a);
fscanf(f,"%s",b);
fscanf(f,"%s",c);
printf("%s %s %s\n",a,b,c);
int la=0,lb=0;
while(a[la]!='\0')la++;
while(b[lb]!='\0')lb++;
//system("pause");
int ai=0,bi=0,ci=0,flag=1;
for(;ci<la+lb-1;)
{
if(c[ci]==a[ai] && ai<la)
{ printf("a");
ai++;
ci++;
}
else if(c[ci]==b[bi] && bi<lb)
{ printf("b");
bi++;
ci++;
}
else
flag=0;
}
if(flag)
printf("Interleaved");
else
printf("Not Interleaved");
getch();
}
#include<conio.h>
main()
{
FILE *f=fopen("slinput.txt","r");
char a[20],b[20],c[40];
fscanf(f,"%s",a);
fscanf(f,"%s",b);
fscanf(f,"%s",c);
printf("%s %s %s\n",a,b,c);
int la=0,lb=0;
while(a[la]!='\0')la++;
while(b[lb]!='\0')lb++;
//system("pause");
int ai=0,bi=0,ci=0,flag=1;
for(;ci<la+lb-1;)
{
if(c[ci]==a[ai] && ai<la)
{ printf("a");
ai++;
ci++;
}
else if(c[ci]==b[bi] && bi<lb)
{ printf("b");
bi++;
ci++;
}
else
flag=0;
}
if(flag)
printf("Interleaved");
else
printf("Not Interleaved");
getch();
}
No comments:
Post a Comment
Have some problem with this code? or Request the code you want if you cant find it in Blog Archive.