#include "declare.h"
void gener(void)
{
 extern int M;
 FILE *f1,*f2;
 double x1,x2,y,x10,x11,x20,x21,y10,y11,hx,hy;
 switch(M)
 {
  case 1: f1 = fopen("data11.dat","w");
	  f2 = fopen("data21.dat","w");
	  break;
  case 2: f1 = fopen("data12.dat","w");
	  f2 = fopen("data22.dat","w");
	  break;
 }
 puts("Введите левую и правую границу области");
 scanf("%lf %lf",&x10,&x11);
 puts("Введите нижнюю и верхнюю границу области");
 scanf("%lf %lf",&x20,&x21);
 puts("Введите нижнюю и верхнюю границу значения функции");
 scanf("%lf %lf",&y10,&y11);
 hx=(x11-x10)/500;
 hy=(y11-y10)/1000;
 fprintf(f1,"%lf %lf %lf %lf\n",x10,x11,x20,x21);
   switch(M)
   {
    case 1:
	for(y=y10;y<y11;y+=hy)
	{
	 x1=x10;
	 hy *=1.2;
	 while(x1<x11)
	 {
	  if(y-(1-x1)*(1-x1)>0.0)
	  {
	   x2 = sqrt(y-(1-x1)*(1-x1))/10.0+x1*x1;
	   if( x20<x2 && x2<x21)
	   fprintf(f1,"%lf %lf %lf\n",x1,x2,y);
	   x2 = -sqrt(y-(1-x1)*(1-x1))/10.0+x1*x1;
	   if( x20<x2 && x2<x21)
	   fprintf(f2,"%lf %lf %lf\n",x1,x2,y);
	  }
	  x1 += hx;
	 }
	}
	 break;

    case 2:
	for(y=y10;y<y11;y+=hy)
	{
	 x1=x10;
	 hy *=1.2;
	 while(x1<x11)
	 {
	  if(y-5*x1*x1>0.0)
	  {
	   x2 = sqrt((y-5*x1*x1)/2)+x1-1.0;
	   if( x20<x2 && x2<x21)
	   fprintf(f1,"%lf %lf %lf\n",x1,x2,y);
	   x2 = -sqrt((y-5*x1*x1)/2)+x1-1.0;
	   if( x20<x2 && x2<x21)
	   fprintf(f2,"%lf %lf %lf\n",x1,x2,y);
	  }
	  x1 += hx;
	 }
	}
	 break;
   }
   fclose(f1);
   fclose(f2);
}
