请帮我把以下的c译成pascal

来源:百度知道 编辑:UC知道 时间:2024/05/20 21:19:45
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#define ID struct id
struct id
{
char name[20];
char tele[20];
ID *next;
};

int pc=0;

ID *creat()
{
ID *p1,*p2,*head;
char str[20];
p1=p2=head=NULL;
printf("\t\t\t 开始输入记录(姓名 # 结束)!\n");
while(1)
{
printf("请输入姓名:\n");scanf("%s",str);getchar();
if(strcmp(str,"#")==0) break;
p1=(ID*)malloc(sizeof(ID));
strcpy(p1->name,str);
printf("请输入电话号码:\n");scanf("%s",p1->tele);getchar();

if(head==NULL)
{
head=p1;
p2=p1;
}
else
{
p2->next=p1;
p2=p1;
}
pc++;
}
p2->next=NULL;
return(head);
}

主要程序修改如下,余下请自己补充。
type
pnext=^id;
id=record
name:string;
tele:string;
next:pnext;
end;

var
pc:integer;
pc:=0;
function create:pnext;
var
p1,p2,head:pnext;
str:string;
begin
p1:=nil;p2:=nil;head:=nil;
writeln('开始输入记录(姓名 # 结束)!');
while (true) do
begin
writeln('请输入姓名:');readln(str);
if (str='#') then break;
new(p1);
p1^.name=str;
writeln('请输入电话号码:');readln(p1^.tele);
if (head=nil) then
begin
head=p1;
p1:=p2;
end
else
begin
p2^.next=p1;
p2:=p1;
end;
inc(pc)
end;
p2^.next:=nil;
result:=head;
end;

这么多啊,百度上搜编程语言通用翻译补丁!