#include <iostream>
#include <conio.h>
#include <string>

using namespace std;

int main()
{

	float a[4][3]={{0,0,0},{0,0,1},{0,1,0},{0,1,1}};
	float w[3]={.1,.2,.3};
	int ya;
	float Error=0;
	float y[4]={1,0,1,1};

	float NET;
	float mu=0.5;
	int i=1;
	c:
	while(i<=4)
	{
		NET=0;
	  for(int j=1;j<=3;j++)
	  {
		
           NET = (w[j]*a[i][j])+NET;
	  }
	  
	  if (NET >0)
	  {
			ya=1;
	  }
	  else
	  {
			ya=0;
	  }
	  
	  Error = y[i]-ya;

	   if ( 0 <= Error <= 0.2)
	  {

        cout<<" the out put y the ANN Trainning  "<<endl;


     cout<<"out_"<<i<<"   ";
		 cout<<y[i]<<"   ";

	  for( int j=1;j<=3;j++)
	  {
          cout<<"A["<<i<<"]["<<j<<"]"<<"   ";
         cout<<a[i][j]<<"   "<<endl;

			  
	  }

		 i++;
	  }
	
	  else
	  {
	   for( int j=1;j<=3;j++)
	  {
         // cout<<"try change"<<i;
              w[j]=w[j]+(mu*a[i][j]*ya);

      }

	  }
	   goto c;

	}

    getch();
    return 0;
}
