谁给我一个介绍pascal的动态分配类似C语言的链表的程序?高分!!!!!!!!!!

meng_tenboy 2001-10-26 08:31:52
...全文
66 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Arter 2001-10-28
  • 打赏
  • 举报
回复
书上写的很明白,你自己认真看吧,不要是什么的求别人!
hsq 2001-10-27
  • 打赏
  • 举报
回复
关键还是你自己要多练练。靠一个程序解决不了问题
lizhenguo 2001-10-27
  • 打赏
  • 举报
回复
type nodetype=record num:integer;p:^nodetype;end;
var head,now:nodetype
begin
new(head);
now:=head
readln(now^.num);
new(now^.p);
now:=now^.p;
...
...
...
CNer 2001-10-27
  • 打赏
  • 举报
回复
下面是我的作业。。。
是建立链表的,你看看。。。


/*
The following function will create a List,
and need to enter data!
*/
int CreateList ()
{
char ch;
struct ListCharacter *NewNode;
/*
Tips!
*/
printf ("\n\n\n\n\nDirect:");
printf ("\n Please press a character to add to the List,");
printf ("\n or press the ENTER key to output the reverse List!");

ch=getch ();
while (ch!=13)
{
/*
Create new node for List!
*/
NewNode=(struct ListCharacter *) malloc (sizeof (struct ListCharacter));
NewNode->Character=ch;
NewNode->Next=NULL;
printf ("%c",ch);
/*
This part will create the List!
*/
if (Head==NULL)
Head=NewNode;
else
This->Next=NewNode;
This=NewNode;

ch=getch ();
/*
Loop create List!
*/
}
/*
Information:
There may be some errors:
The following sentences will cause some errors in Microsoft Visual
C++ 6.0 Complier.
The execute file produced by Microsoft Visual C++ 6.0 may also cause a
general protect error!
But,Borland Turbo C 2.0 complier will not occur!
Why?

when conner presses "ENTER" key without pressing any other key before!
The value of "Head->Character" will be unsureness!
The pointer points to a unknow memory area!
The default value of "Head->Character" is Enter(ASCII 13).
The solution of the problems above can be:
*/
if (Head==NULL) Head->Character =ch;
return (1);
}
/*
chenggn 2001-10-27
  • 打赏
  • 举报
回复

new(p);
dispose(p);

还有getmem 之类
建议你看看超星的 <turbo pascal 大全>

33,028

社区成员

发帖
与我相关
我的任务
社区描述
数据结构与算法相关内容讨论专区
社区管理员
  • 数据结构与算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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