展开全部
#include <stdio.h>
#include <stdlib.h>
typedef struct _Score
{
int id;
float Mscore;
struct _Score *next;
}Score;
Score *head;
int main()
{
int dangqian=0;
int count=2;
Score *Last;
Score *temp;
head=(Score *)malloc(sizeof(Score));
printf("Input Student Id:");
scanf("%d",&head->id);
printf("\n");
printf("Input Student Score");
scanf("%f",&head->Mscore);
Last=head;
head->next=(Score *)malloc(sizeof(Score));
Last=head->next;
printf("Input Student Id:");
scanf("%d",&Last->id);
printf("\n");
printf("Input Student Score");
scanf("%f",&Last->Mscore);
Last->next=NULL;
temp=head;
//print
dangqian=0;
while(dangqian<count)
{
printf("id Number:%d",temp->id);
printf("\n");
printf("Score:%f",temp->Mscore);
dangqian++;
temp=temp->next;
}
return 0;
}
不知道能不能正常运行哦。
#include <stdlib.h>
typedef struct _Score
{
int id;
float Mscore;
struct _Score *next;
}Score;
Score *head;
int main()
{
int dangqian=0;
int count=2;
Score *Last;
Score *temp;
head=(Score *)malloc(sizeof(Score));
printf("Input Student Id:");
scanf("%d",&head->id);
printf("\n");
printf("Input Student Score");
scanf("%f",&head->Mscore);
Last=head;
head->next=(Score *)malloc(sizeof(Score));
Last=head->next;
printf("Input Student Id:");
scanf("%d",&Last->id);
printf("\n");
printf("Input Student Score");
scanf("%f",&Last->Mscore);
Last->next=NULL;
temp=head;
dangqian=0;
while(dangqian<count)
{
printf("id Number:%d",temp->id);
printf("\n");
printf("Score:%f",temp->Mscore);
dangqian++;
temp=temp->next;
}
return 0;
}
不知道能不能正常运行哦。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询