text: #include <bitsdc++.h>
  using namespace std;
  const double e = 2.718281828459045;
  const float Eta = 0.5; //学习速率；
  const int HLN_number = 10;
  const int OLN_number = 2;
  const int input_number = 225;
  int input[input_number], trian_times = 1000;
  struct hidden_layer_neure
  {
      double w[input_number];
      double b;
      double net;
      double out;
  } h[HLN_number];
  struct output_layer_neure
  {
      double w[HLN_number];
      double b;
      double net;
      double out;
      double target;
  } o[OLN_number];
  
  double sigmoid(double x)
  {
      int y = -1 * x;
      return 1 / (1 + pow(e, y));
  }
  
  double delta_o(int i)
  {
      return (o[i].out - o[i].target) * o[i].out * (1 - o[i].out);
  }
  
  double delta_h(int i)
  {
      double temp = 0;
      for (int j = 0; j < OLN_number; j++)
          temp += delta_o(j) * o[j].w[i];
      return temp * h[i].out * (1 - h[i].out);
  }
  
  int main()
  {
      //读数据
      FILE *fp;
      fp = fopen("inputs.txt", "r");
      for (int i = 0; i < input_number; i++)
          fscanf(fp, "%d", &input[i]);
      fclose(fp);
      fp = fopen("HLN_weights.txt", "r");
      for (int i = 0; i < HLN_number; i++)
      {
          for (int j = 0; j < input_number; j++)
              fscanf(fp, "%lf", &h[i].w[j]);
      }
      fclose(fp);
      fp = fopen("OLN_weights.txt", "r");
      for (int i = 0; i < OLN_number; i++)
      {
          for (int j = 0; j < HLN_number; j++)
              fscanf(fp, "%lf", &o[i].w[j]);
      }
      fclose(fp);
      fp = fopen("HLN_bias.txt", "r");
      for (int i = 0; i < HLN_number; i++)
          fscanf(fp, "%lf", &h[i].b);
      fclose(fp);
      fp = fopen("OLN_bias.txt", "r");
      for (int i = 0; i < OLN_number; i++)
          fscanf(fp, "%lf", &o[i].b);
      fclose(fp);
      fp = fopen("targets.txt", "r");
      for (int i = 0; i < OLN_number; i++)
          fscanf(fp, "%lf", &o[i].target);
      fclose(fp);
      while (trian_times--)
      {
          //正向传播；
          for (int i = 0; i < HLN_number; i++)
          {
              h[i].net = h[i].b;
              for (int j = 0; j < input_number; j++)
                  h[i].net += input[j] * h[i].w[j];
              h[i].out = sigmoid(h[i].net);
          }
          for (int i = 0; i < OLN_number; i++)
          {
              o[i].net = o[i].b;
              for (int j = 0; j < HLN_number; j++)
                  o[i].net += h[j].out * o[i].w[j];
              o[i].out = sigmoid(o[i].net);
          }
          //反向传播，先更新从输入层到隐藏层的权值；
          for (int i = 0; i < OLN_number; i++)
          {
              o[i].b -= Eta * delta_o(i) * 1;
              for (int j = 0; j < HLN_number; j++)
                  o[i].w[j] -= Eta * delta_o(i) * h[j].out;
          }
          for (int i = 0; i < HLN_number; i++)
          {
              h[i].b -= Eta * delta_h(i) * 1;
              for (int j = 0; j < input_number; j++)
                  h[i].w[j] -= Eta * delta_h(i) * input[j];
          }
          for (int i = 0; i < OLN_number; i++)
              printf("%lf ", o[i].out);
          printf("\n");
      }
      //写数据
      fp = fopen("inputs.txt", "w");
      for (int i = 0; i < input_number; i++)
          fprintf(fp, "%d", &input[i]);
      fclose(fp);
      fp = fopen("HLN_weights.txt", "w");
      for (int i = 0; i < HLN_number; i++)
      {
          for (int j = 0; j < input_number; j++)
              fprintf(fp, "%lf", &h[i].w[j]);
      }
      fclose(fp);
      fp = fopen("OLN_weights.txt", "w");
      for (int i = 0; i < OLN_number; i++)
      {
          for (int j = 0; j < HLN_number; j++)
              fprintf(fp, "%lf", &o[i].w[j]);
      }
      fclose(fp);
      fp = fopen("HLN_bias.txt", "w");
      for (int i = 0; i < HLN_number; i++)
          fprintf(fp, "%lf", &h[i].b);
      fclose(fp);
      fp = fopen("OLN_bias.txt", "w");
      for (int i = 0; i < OLN_number; i++)
          fprintf(fp, "%lf", &o[i].b);
      fclose(fp);
      return 0;
  }