编程论坛's Archiver

armacd 发表于 2008-5-10 18:17

求助

#include<stdio.h>
//#include<malloc.h>
struct student
{
char num[10];
char name[10];
int age;
struct student *next;
};

void insert(struct student *t_head);
void input(struct student *pp);
void display(struct student *t_head);

void main()
{
student *head;
head= new student;
head->next=NULL;
int i;
for(i=0;i<4;i++)
insert(head);
display(head);
}

void insert(struct student *t_head)
{
struct student *pt,*ps;
pt= new student;
input(pt);
for(ps=t_head;ps->next!=NULL;ps=ps->next);
pt->next=NULL;
ps->next=pt;
}

void input(struct student *pp)
{
printf("\n Please enter a num: ");
scanf("%s",pp->num);
printf("\n Please enter a name: ");
scanf("%s",pp->name);
printf("\n Please enter a age: ");
scanf("%d ",&pp->age);
}

void display(struct student *t_head)
{
struct student *ps;
for(ps=t_head; ps->next!=NULL;ps=ps->next)
{
printf("\n num: %s, name: %s, age: %d ",
ps->next->num,
ps->next->name,
ps->next->age );
}
}
运行以后怎摸操作呀
请给出完整操作
没有插入的功能吗? inset input 功能怎摸用
输入完第一个怎摸没有显示 只有输入数字才显示
都输入完也没显示
加个删除功能怎摸加   加完怎摸操作   谢谢

armacd 发表于 2008-5-12 13:38

加个删除功能即可

mqh21364 发表于 2008-5-12 14:44

摸。。。。。。。。。。。。。。。。。。。。。。

[tk13] [tk13] [tk13] [tk13] [tk13]

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.