#include<iostream.h>
#include<fstream.h>
#include<math.h>

struct knn
{
	int age;
	int sp;
	int asti;
	int tpr;
	int type;
}str[11],st[2];

int main()
{
	int i=0;
	int w=1;
	int range=1;
	double sum[2][11];
	ifstream flie2;
   flie2.open("knowledg base.txt",ios::in);

do
   {
		   flie2>>str[i].age;
		   flie2>>str[i].sp;
		   flie2>>str[i].asti;
		   flie2>>str[i].tpr;
		   flie2>>str[i].type;


		   i++;
   }while(!flie2.eof());
flie2.close();

for( i=0;i<11;i++)
   {
	   cout<<"   Age ";
	    cout<<str[i].age;
	   cout<<"   Sp ";
	     cout<<str[i].sp;
		cout<<"   Asti ";
		  cout<<str[i].asti;
		 cout<<"   Tpr ";
		   cout<<str[i].tpr;
	   	  cout<<"   type ";
		    cout<<str[i].type;
		   cout<<endl;
		   cout<<endl;

   }


for( i=0;i<2;i++)
   {
	   cout<<"\tEnter Age";
	   cin>>st[i].age;
	   cout<<"\tEnter Sp";
	    cin>>st[i].sp;
		cout<<"\tEnter Asti";
		 cin>>st[i].asti;
		 cout<<"\tEnter Tpr";
		  cin>>st[i].tpr;
	   	  cout<<"\tEnter type";
		   cin>>st[i].type;
		   cout<<endl;
		    cout<<endl;

   }
for(int j=0;j<2;j++)
{
for(i=0;i<11;i++)
{
	sum[j][i]=(w*(abs((st[j].age-str[i].age))/range
	+abs((st[j].asti-str[i].asti))/range
	+abs((st[j].sp-str[i].sp))/range
	+abs((st[j].tpr-str[i].tpr))/range)/4)*100;
//cout<<sum[i][j]<<"  ";
}
//cout<<endl;
}


for( j=0;j<2;j++)
{
for(i=0;i<11;i++)
{

	if(sum[i][j]==1)
	{
		cout<<i<<endl;
		cout<<str[i].type;

		if(str[i].type==1)
			cout<<"  give sold\n";
		if(str[i].type==2)
			cout<<"  give lina\n";
		if(str[i].type==3)
			cout<<"  not give\n";
		break;
	}
else
{
		if(sum[j][i]>1)
		{
		cout<<i<<endl;
		cout<<str[i].type;

		if(str[i].type==1)
			cout<<"  give sold\n";
		if(str[i].type==2)
			cout<<"  give lina\n";
		if(str[i].type==3)
			cout<<"  not give\n";
		break;
		}
	}

}}







   return 0;
}


























