struct Item
{
float x;
float y;
COLORREF color;
Item *next;
};class List
{
public:
void crea(CDC *pDC);
List();
virtual ~List();
private:
Item *list;//链表头
Item *tail;//链表尾
};
---------------------------------------------------------------------------------------
void List::crea(CDC *pDC)
{
float x0,y0,r,t1,t2,e,temp1,temp2,temp3,temp4;
float t;
int i;
CPen pen;
pen.CreatePen(PS_SOLID,1,RGB(0,0XFF,0));
CPen *oldpen=(CPen*)pDC->SelectObject(&pen);
for(i=1;i<NUM;i++)
{
Item *pt1,*pt2,*p=new Item;
x0=rand()%640;
y0=rand()%480;
r=20.0;
t1=0.0;
t2=PI;
e=0.0001;
temp1=x0+r*cos(t1);//程序运行到这里就不动了????????
pt1->x=temp1;
temp2=y0+r*sin(t1); ↑
pt1->y=temp2; |
pt1->color=i; |
pDC->MoveTo(x0+r*cos(t1),y0+r*sin(t1)); |
for(t=t1;t<=t2;t+=e) |
{ |
temp3=x0+r*cos(t);
pt2->x=temp3;
temp4=y0+r*sin(t); |
pt2->y=temp4;
pt2->color=i;
pDC->LineTo(x0+r*cos(t),y0+r*sin(t)); |
if(list==NULL)
{ |
list=pt1;
p->next=pt2; |
p=pt2;
p->next=NULL; |
}
else |
{
p->next=pt2; |
p=pt2->next;
p->next=NULL; | } |
|
}
} |
} |
------------------------------------
我想在屏幕上画些随机的圆弧,并把圆弧上的点保存到链表里,代码如上,出问题的地方|如箭头所示,请教达人解决的方法
{
float x;
float y;
COLORREF color;
Item *next;
};class List
{
public:
void crea(CDC *pDC);
List();
virtual ~List();
private:
Item *list;//链表头
Item *tail;//链表尾
};
---------------------------------------------------------------------------------------
void List::crea(CDC *pDC)
{
float x0,y0,r,t1,t2,e,temp1,temp2,temp3,temp4;
float t;
int i;
CPen pen;
pen.CreatePen(PS_SOLID,1,RGB(0,0XFF,0));
CPen *oldpen=(CPen*)pDC->SelectObject(&pen);
for(i=1;i<NUM;i++)
{
Item *pt1,*pt2,*p=new Item;
x0=rand()%640;
y0=rand()%480;
r=20.0;
t1=0.0;
t2=PI;
e=0.0001;
temp1=x0+r*cos(t1);//程序运行到这里就不动了????????
pt1->x=temp1;
temp2=y0+r*sin(t1); ↑
pt1->y=temp2; |
pt1->color=i; |
pDC->MoveTo(x0+r*cos(t1),y0+r*sin(t1)); |
for(t=t1;t<=t2;t+=e) |
{ |
temp3=x0+r*cos(t);
pt2->x=temp3;
temp4=y0+r*sin(t); |
pt2->y=temp4;
pt2->color=i;
pDC->LineTo(x0+r*cos(t),y0+r*sin(t)); |
if(list==NULL)
{ |
list=pt1;
p->next=pt2; |
p=pt2;
p->next=NULL; |
}
else |
{
p->next=pt2; |
p=pt2->next;
p->next=NULL; | } |
|
}
} |
} |
------------------------------------
我想在屏幕上画些随机的圆弧,并把圆弧上的点保存到链表里,代码如上,出问题的地方|如箭头所示,请教达人解决的方法
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货