📄 subject_51788.htm
字号:
<p>
序号:51788 发表者:鹏程 发表日期:2003-09-04 11:30:05
<br>主题:请朋友们给我看看,谢谢
<br>内容:请朋友们给我看看,下面的程序错在哪?为什么main()中的showlist(h);还没有执行就结束了呢?<BR><BR>//chaintable.cpp<BR>/////////////////////////////////////////////////////////////////////<BR>#include<iostream.h><BR><BR>/////////////////////////////////////////////////////////////////////<BR>struct coor //结点结构定义<BR>{<BR> int x;<BR> int y;<BR> struct coor* next; <BR>};<BR><BR>struct polygon //多边形结构体定义<BR>{<BR> int number;<BR> struct coor coordinate;<BR> struct polygon* next;<BR>};<BR><BR>polygon *head; //多边形结链首指针<BR>/////////////////////////////////////////////////////////////////////<BR>polygon *Create()<BR>{<BR> polygon *pops;<BR> polygon *popend;<BR> pops=new polygon;<BR> popend=pops;<BR> head=NULL;<BR> coor *cops;<BR> coor *copend;<BR> int j=1;<BR> while(j)<BR> {<BR> cout<<"请输入多边形的边数(number>=3)=:"<<endl;<BR> cin>>pops->number;<BR> cout<<endl;<BR> cout<<"请输入坐标值:"<<endl;<BR> cops=new coor;<BR> cops=&(pops->coordinate);<BR> copend=cops;<BR> for(int i=0;i<pops->number;i++)<BR> {<BR> cin>>cops->x>>cops->y;<BR> cops=new coor;<BR> copend->next=cops;<BR> copend=cops;<BR> }<BR> cops=NULL;<BR> if(head=NULL)<BR> head=pops;<BR> else<BR> popend->next=pops;<BR> popend=pops;<BR> pops=new polygon;<BR> cout<<"请按任意大于0的数字键开始下一多边形各顶点坐标的输入,"<BR> <<"否则按0键结束输入:"<<endl;<BR> cin>>j;<BR> }<BR> popend->next=NULL;<BR> delete pops;<BR> return head;<BR>}<BR>/////////////////////////////////////////////////////////////////////<BR>void showlist(polygon *head)<BR>{<BR> int i=1;<BR> cout<<" "<<endl;<BR> while(head)<BR> {<BR> coor* cohead;<BR> cohead=&head->coordinate;<BR> cout<<"第"<<i<<"多边形各顶点坐标如下:"<<endl;<BR> while(head->number)<BR> {<BR> cout<<"("<<cohead->x<<","<<cohead->y<<")"<<endl;<BR> cohead=cohead->next;<BR> head->number--;<BR> }<BR> head=head->next;<BR> i++;<BR> }<BR>}<BR>/////////////////////////////////////////////////////////////////////<BR>void main()<BR>{<BR> polygon* h=Create();<BR> showlist(h);<BR>}<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:天才 回复日期:2003-09-04 11:37:54
<br>内容:在if(head=NULL)这行<BR>应该是if(head==NULL)
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:鹏程 回复日期:2003-09-04 12:03:03
<br>内容:非常感谢!!<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:天才 回复日期:2003-09-04 15:26:33
<br>内容:举手之劳,不谢不谢。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -