#include<stdio.h>
typedef struct node{
float money;
char num[10];
struct node *link;
}stud;
stud *ph,*pt,*ps,*p;
int main(){
int n,i;
ph=pt=ps=NULL;
if((pt=(stud*)malloc(sizeof(stud)))==NULL) exit(-1);
scanf("%s %.1f",pt->stud.num,&pt->stud.money);
pt->link=NULL;
if(ph==NULL)
ph=ps=pt;
printf("输入队列数\n ");
scanf("%d",&n) ;
for(i=0;i<n;i++){
if((pt=(stud*)malloc(sizeof(stud)))==NULL) exit(-1);
printf("输入一卡通号码\n 输入充值金额(大于10,小于1000)");
scanf("%s %.1f",pt->stud.num,&pt->stud.money);
pt->link=NULL;
if(ps!=NULL){
pt->link=NULL;
ps->link=pt;
ps=pt;
}
}
if(getchar()=='~')
break;
pt=ph;
do
{printf("一卡通号码:%s\n充值金额:%.1f",p->stud.num,p->stud.money);
p=p->next;
}while(p!=NULL);
return 0;
}
麻烦大佬 拜谢
#include
#include
typedef struct node{
float money;
char num[10];
struct node *link;
}stud;
stud *ph,*pt,*ps,*p;
int main(){
int n,i;
ph=pt=ps=NULL;
if((pt=(stud*)malloc(sizeof(stud)))==NULL) exit(-1);
scanf("%s %.1f",pt->num,pt->money);
pt->link=NULL;
if(ph==NULL)
ph=ps=pt;
printf("输入队列数\n ");
scanf("%d",&n) ;
for(i=0;inum,pt->money);
pt->link=NULL;
if(ps!=NULL){
pt->link=NULL;
ps->link=pt;
ps=pt;
}
}
pt=ph;
do
{printf("一卡通号码:%s\n充值金额:%.1f",p->num,p->money);
p=p->link;
}while(p!=NULL);
return 0;
}