这个问题有点晕,请高手指教
//学生系统(引用&附加头结点)//预定义
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<malloc.h>
#define NULL 0
#define LEN sizeof(struct student)
//存储结构
struct student{
long num;//学号
char name[20];//姓名
float English,Math,Computer;//各科成绩
struct student *next;//指针域
};
int n;
//基本操作
struct student *creat(void){ //创建链表
struct student *head;
struct student *p1,*p2;
n=0;
p1=p2 =(struct student *)malloc(LEN);
scanf("%ld,%10s,%f,%f,%f",&p1->num,p1->name,&p1->English,&p1->Math,&p1->Computer);
head=NULL;
while(p1->num!=0){
n=n+1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
scanf("%ld,%10s,%f,%f,%f",&p1->num,p1->name,&p1->English,&p1->Math,&p1->Computer);
}
p2->next=NULL;
return(head);
}
void print(struct student *head){ //输出
struct student *p;
printf("\nNOW,These %d recordes are:\n",n);
printf("num\t\tname\tEnglish\tMath\tComputer");
p=head;
if(head!=NULL)
while(p!=NULL)
{printf("\n%ld\t%10s\t%f\t%f\t%f\n",p->num,p->name,p->English,p->Math,p->Computer);
p=p->next;
}
}
void main(){
clrscr();//清屏
struct student *head,stu;
long del_num;
printf("input records:");
head=creat();
print(head);
printf("\ninput the deleted number:");
getch();//暂停
}
以上是我作的关于学生系统的程序(链表).
我的测试结果显示太不美观,并且我觉的还有一点错误
在name之后的数据有问题,
请指教,谢谢.