Silmeria |
2007-06-25 08:25 |
复制代码 #define NULL 0 struct student {int num; int score; struct student *next; }; int n; main() {struct student *head,*p1,*p2,*p; n=0; p1=p2=(struct student * ) malloc(sizeof(struct student)); scanf("%d,%d",&p1->num,&p1->score); head=NULL; while(p1->num!=0) {n=n+1; if(n==1)head=p1; else p2->next=p1; p2=p1; p1=(struct student * ) malloc(sizeof(struct student)); scanf("%d,%d",&p1->num,&p1->score); } printf("\n %d records are:\n",n); p=head; if(head!=NULL) do {printf("\n%d %d",p->num,p->score); p=p->next; } while(p!=NULL); }
|
关于float类型的动态列表的建立,其中一个相关的例子.你可以参考一下.Tc2通过. |
|