if(p2[0]==x[i])
z=y[i];
}
MoveToEx(hdc,p2[0]*5+100,768-(z*2+200),NULL);
for(intp=p2[0];p<100;p++)
{
doubley=a[0][m+1];
for(intq=1;q<=m;q++)
y+=a[q][m+1]*pow((float)p,q);
//TextOut(hdc,p+100,768-(y+100),"**",1);
LineTo(hdc,p*5+100,768-(y*2+200));
}
cout<delete[]w;
DeleteObject;
}
else
cout<<"error"<}
int_tmain(intargc,_TCHAR*argv[])
{
for(;;){
intnumber,m;
cout<<"请输入w最高次数"<cin>>m;
cout<<"请输入点的个数"<cin>>number;
srand((unsigned)time(NULL));
float*x,*y,*p1;
POINT*point;
x=newfloat[number];
y=newfloat[number];
p1=newfloat[number];
point=newPOINT[number];
if(x!
=NULL){//判断内存是否申请成功
if(y!
=NULL){
if(point!
=NULL){
for(inti=0;i{
x[i]=rand()%100;
p1[i]=x[i];
y[i]=100*sin(0.1*x[i])+(rand()%100)*0.3;//随机数的产生
//cout<//cout<}
for(intj=0;jfor(inti=0;iif(p1[i]>p1[i+1])
{
inttemp=p1[i+1];
p1[i+1]=p1[i];
p1[i]=temp;
}
}
for(inti=0;i{
point[i].x=x[i];
point[i].x=y[i];
}
ofstreamfile("samp.text",ios_base:
:
out);//记录带噪声的点的集合
file.write(reinterpret_cast(&point),sizeof(point));
DeviceContextdc;
HDChdc=dc.GetCurDC();
HPENHPen1=CreatePen(PS_SOLID,2,RGB(0,0,0));
SelectObject(hdc,HPen1);
MoveToEx(hdc,x[0]+100,768-(y[0]),NULL);
for(inti=0;i{
TextOut(hdc,x[i]*5+100,768-(y[i]*2+200),"*",2);
}
solve(m,number,x,y,p1);
delete[]x;//释放内存
delete[]y;
DeleteObject;//删除画笔
intm1;
cout<<"请输入w最高次数"<cin>>m1;
srand((unsigned)time(NULL));
float*x1,*y1,*p2;
POINT*point1;
x1=newfloat[number];
y1=newfloat[number];