//	This source and similar text sequences method apply to GNU General Public License. 
//			Copyright (C) 2001-2014 Jasenko Dzinleski 

//		This program is free software; you can redistribute it
//	and/or modify it under the terms of the GNU General Public License as
//	published by the Free Software Foundation; either version 2 of the
//	License, or (at your option) any later version. 

//	This program is distributed in the hope that it will be useful, but
//	WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//	General Public License for more details. 

//	You should have received a copy of the GNU General Public License along
//	with this program; if not, write to the Free Software Foundation, Inc.,
//	51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

//  Similar Text Sequences 
//	written by Dzinleski Jasenko  March 2014

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

FILE		*f1,*f2;

char		infn[256]="b_1.txt";

char		cv[256];int cvi=0;
char		nl[256];int nli=0;

int		cic[10][2];
int		ckc[10];

int main(int argc,char *argv[])
{

int	a,b,c,c1,c2,c3,c4,c5,c6,c7,c8;
int	i,j,k,l,m,n;
int	fb;
int	nc=1;
int	v;

	f1=fopen(infn,"rb");
	fb=getc(f1);
	while(!feof(f1))
	{
		cvi=0;while((fb!=10)&&(fb!=13)){cv[cvi]=fb;++cvi;fb=getc(f1);}
		if(nli==0){while((fb==10)||(fb==13)){nl[nli]=fb;++nli;fb=getc(f1);}}else{
			j=0;while((fb==10)||(fb==13)){if(nl[j]==fb){++j;if(j==nli){j=0;++nc;}}fb=getc(f1);}
		}

		//printf("%s\n",cv);

		//	03 01 00 01 02 02 00 01
		//	03 00 01 01 02 02 01 00 


		cic[0][0]=01;
		cic[0][1]=99;

		cic[1][0]=01;
		cic[1][1]=99;

		cic[2][0]=00;
		cic[2][1]=00;

		cic[3][0]=01;
		cic[3][1]=99;

		cic[4][0]=02;
		cic[4][1]=99;

		cic[5][0]=02;
		cic[5][1]=99;

		cic[6][0]=00;
		cic[6][1]=00;

		cic[7][0]=01;
		cic[7][1]=99;

		c1=0;c2=0;c3=0;c4=0;c5=0;c6=0;c7=0;c8=0;
		v=10*(-48+(int)cv[0] )+(-48+(int)cv[1] );if(v>=cic[0][0]&&v<=cic[0][1]){++c1;}
		v=10*(-48+(int)cv[2] )+(-48+(int)cv[3] );if(v>=cic[1][0]&&v<=cic[1][1]){++c2;}
		v=10*(-48+(int)cv[4] )+(-48+(int)cv[5] );if(v>=cic[2][0]&&v<=cic[2][1]){++c3;}
		v=10*(-48+(int)cv[6] )+(-48+(int)cv[7] );if(v>=cic[3][0]&&v<=cic[3][1]){++c4;}
		v=10*(-48+(int)cv[8] )+(-48+(int)cv[9] );if(v>=cic[4][0]&&v<=cic[4][1]){++c5;}
		v=10*(-48+(int)cv[10])+(-48+(int)cv[11]);if(v>=cic[5][0]&&v<=cic[5][1]){++c6;}
		v=10*(-48+(int)cv[12])+(-48+(int)cv[13]);if(v>=cic[6][0]&&v<=cic[6][1]){++c7;}
		v=10*(-48+(int)cv[14])+(-48+(int)cv[15]);if(v>=cic[7][0]&&v<=cic[7][1]){++c8;}

		//printf("%d %d %d %d %d %d %d %d\n",c1,c2,c3,c4,c5,c6,c7,c8);

		ckc[0]=0;
		ckc[1]=1;
		ckc[2]=1;
		ckc[3]=0;
		ckc[4]=0;
		ckc[5]=1;
		ckc[6]=1;

		if(ckc[0]==0){if((c1>=1)&&(c2>=1)){c1=1;}else{c1=0;}}
		if(ckc[0]==1){if((c1>=1)||(c2>=1)){c1=1;}else{c1=0;}}
		if(ckc[1]==0){if((c2>=1)&&(c3>=1)){c2=1;}else{c2=0;}}
		if(ckc[1]==1){if((c2>=1)||(c3>=1)){c2=1;}else{c2=0;}}
		if(ckc[2]==0){if((c3>=1)&&(c4>=1)){c3=1;}else{c3=0;}}
		if(ckc[2]==1){if((c3>=1)||(c4>=1)){c3=1;}else{c3=0;}}
		if(ckc[3]==0){if((c4>=1)&&(c5>=1)){c4=1;}else{c4=0;}}
		if(ckc[3]==1){if((c4>=1)||(c5>=1)){c4=1;}else{c4=0;}}
		if(ckc[4]==0){if((c5>=1)&&(c6>=1)){c5=1;}else{c5=0;}}
		if(ckc[4]==1){if((c5>=1)||(c6>=1)){c5=1;}else{c5=0;}}
		if(ckc[5]==0){if((c6>=1)&&(c7>=1)){c6=1;}else{c6=0;}}
		if(ckc[5]==1){if((c6>=1)||(c7>=1)){c6=1;}else{c6=0;}}
		if(ckc[6]==0){if((c7>=1)&&(c8>=1)){c7=1;}else{c7=0;}}
		if(ckc[6]==1){if((c7>=1)||(c8>=1)){c7=1;}else{c7=0;}}

		if(c1&&c2&&c3&&c4&&c5&&c6&&c7){for(j=0;j<cvi;++j){printf("%c",cv[j]);}printf("\n");}

	}
	return(0);

}