哪个好心的人能给我个简单的四、五十行的c语言程序设计

来源:百度知道 编辑:UC知道 时间:2024/06/18 05:48:53
各位大哥大姐们 帮帮小妹一把吧 跪求了

/*c语言最经典的链表*/
#include"stdio.h"
#include"malloc.h"
#define NULL 0
#define L sizeof(struct integer)
struct integer /*定义结构体*/
{
int num;
int zhengshu;
struct integer *next;
};
int n; //纪录链表的长度
struct integer *creat(void) /*创建链表*/
{
struct integer *head;
struct integer *p1,*p2;
n=0;
p1=p2=(struct integer *)malloc(L);
scanf("%d,%d",&p1->num,&p1->zhengshu);
head=NULL;
while(p1->num!=0)
{
n=n+1;
if(n==1) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct integer *)malloc(L);
scanf("%d,%d",&p1->num,&p1->zhengshu);
}
p2->next=NULL;
return(head);
}

void print(struct integer *head) /*打印链表中的数据*/
{
struct integer *p;
printf("Now