满意答案
gamemark
2014.06.15
采纳率:43% 等级:8
已帮助:314人
vs2008测试通过,如果满意请采纳
#include
#include
#pragma runtime_checks( "scu", off )
struct stu
{
char stu_name[10];
float english_score;
struct stu *next;
};
void main()
{
int x=0;
char listx[10],listy[]="yes";
float score_sum=0;
float score_average=0;
struct stu *p1,*p2,*head;
p1=p2=(struct stu *)malloc(sizeof(struct stu));
printf("请输入学生姓名:");
scanf("%s",&p1->stu_name);
printf("请输入英语成绩:");
scanf("%f",&p1->english_score);
score_sum=p1->english_score;
x++;
printf("\n请选择是否继续录入:");
scanf("%s",&listx[0]);
while(strcmp(listx,listy) == 0)
{
p1=(struct stu *)malloc(sizeof(struct stu));
printf("请输入学生姓名:");
scanf("%s",&p1->stu_name);
printf("请输入英语成绩:");
scanf("%f",&p1->english_score);
score_sum=score_sum+p1->english_score;
x++;
p2->next=p1;
p2=p1;
printf("\n请选择是否继续录入:");
scanf("%s",&listx[0]);
}
p1->next=NULL;
score_average=score_sum/x;
printf("\n英语平均成绩为:%3.1f",score_average);
}
00分享举报