这个为啥无法运行呢

秦帅 2019-06-19 03:58:14
#include<iostream>
#include<graphics.h>
using namespace std;
struct Node
{
int x;
int y;
struct Node * next;
int flag;

};
typedef struct Node node;
node * head_1 = NULL;
node * head_2 = NULL;
node * input(node *);
void draw(node *);
int main(void)
{
head_1=input(head_1);
head_2=input(head_2);
initgraph(640,480);
setcolor(GREEN);
draw(head_1);
draw(head_2);
getch();
closegraph();
return 0;
}
node * input(node *)
{
cout << "输入第1个点" << endl;
char c;
node * p = NULL;
head_1 = (node *)malloc(sizeof(node));
cin >> head_1->x;
cin >> head_1->y;
head_1->flag = 0;
head_1->next = NULL;
cout << "是否继续 y or n " << endl;
cin >> c;
if (c == 'y')
{
do
{
node *a = head_1;
p = (node *)malloc(sizeof(node));
cout << "输入顶点坐标\n";
cin >> p->x >> p->y;
p->flag = 0;
p->next = NULL;
while (a->next != NULL)
{
a = a->next;
}
a->next = p;
cout << "是否继续 y or n " << endl;
cin >> c;
} while (c == 'y');
}
p->next = head_1;
return head_1;
}
void draw(node * head)
{
node * p = head;
node * q = head->next;
while (1)
{
line(p->x, p->y, q->x, q->y);
p = p->next;
q = q->next;
if (q == head->next)
{
break;
}
}
}




...全文
25 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2019-06-19
  • 打赏
  • 举报
回复
数据结构对单链表进行数据排序 http://bbs.csdn.net/topics/392201633
赵4老师 2019-06-19
  • 打赏
  • 举报
回复

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧