1、首先,定义一个数据结构student,包含学生的各信息。
2、定义两个student类型的变量,保存所有学生的成绩信息和临时变量。
3、定义一个自定义函数,输入学生的成绩信息。
4、具体实现学生信息的输入,并计算总分。
5、主函数中,先定义4个整型变量,保存学生的总数,以及控制循环的变量。
6、接着,输入学生总数,保存在变量n中。
7、运行程序查看最后结果。
注意事项:
C++不仅拥有计算机高效运行的实用性特征,同时还致力于提高大规模程序的编程质量与程序设计语言的问题描述能力。
这道题我已在另一地方回答——
http://zhidao.baidu.com/question/255870848.html?sort=6&old=1#answer-1404748948
以下是去掉最后一个条件——“再输入一个成绩值 将成绩大于该值的学生信息输出”。。。的解答!
#include
#include
#include
struct stud_node{
int num;
char name[20];
int score;
struct stud_node *next;
};
void main()
{
struct stud_node *head,*tail, *p;
int num, score;
char name[20];
int size = sizeof(struct stud_node);
head=tail=NULL;
scanf("%d", &num);
while(num != 0){
scanf("%s%d",name,&score);
p=(struct stud_node*)malloc(size);
p->num=num;
strcpy(p->name,name);
p->score=score;
p->next=NULL;
if(head==NULL)
head=p;
else
tail->next=p;
tail=p;
scanf("%d",&num);
}
for(p=head; p!=NULL; p=p->next)
printf("%d %s %d\n", p->num,p->name,p->score);
}
#include
#include
#include
struct stud_node{
int num;
char name[20];
int score;
struct stud_node*next;
};
int main(void)
{
struct stud_node *head,*p,*tail;
int num,score,m;
char name[20];
struct stud_node *ptr;
int size=sizeof(struct stud_node);
head=tail=NULL;
printf("Input num,nameandscore:\n");
scanf("%d",&num);
while(num!=0){
scanf("%s%d",name,&score);
p=(struct stud_node*)malloc(size);
p->num=num; strcpy(p->name,name);
p->score=score;
if(head==NULL){
head=p;
tail = p;
}
else
tail->next=p;
tail=p;
scanf("%d",&num);
}
printf("please enter m:");
scanf("%d",&m);
if(head==NULL){
printf("\n no records");
return 0;
}
for(ptr=head;ptr;ptr=ptr->next) {
if(ptr->score>=m)
printf("%8d%20s%6d\n",ptr->num,ptr->name,ptr->score);
}
return 0;
}
zju的作业?