level 10
Thanks桥
楼主
这次是调试以后,还是搞不懂啊。。。@itsvzc
@richard122
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct stud_node{
int num;
char name[20];
int score;
struct stud_node *next;
};
struct stud_node *Creat_Stu_Doc();
struct stud_node *DeleteDoc(struct stud_node *head,int min_score);
void Ptrint_Stu_Doc(struct stud_node *head);
void main()
{
struct stud_node *head;
int min_score;
head=Creat_Stu_Doc();
scanf("%d",&min_score);
head=DeleteDoc(head,min_score);
Ptrint_Stu_Doc(head);
}
struct stud_node *Creat_Stu_Doc()
{
struct stud_node *p , *tail , *head;
int num , score;
char name[20];
tail=head=NULL;
scanf("%d",&num);
while(num!=0){
scanf("%s%d",name,&score);
p=(struct stud_node*)malloc(sizeof(struct stud_node));
p->num=num;
p->score=score;
strcpy(p->name,name);
if(head==NULL)
head=p;
else
tail->next=p;
tail=p;
scanf("%d",&num);
p->next=NULL;}
return head;
}
struct stud_node *DeleteDoc(struct stud_node *head,int min_score)
{
struct stud_node *str1,*str2,*str;
str1=head;
while(str1->score<min_score)
str1=str1->next;
str=str1;
while(str1!=NULL){
str2=str1->next;
if(str2==NULL)
break;
if(str2->score<min_score){
str1->next=str2->next;
free(str2);}
str1=str1->next;}
return str;
}
void Ptrint_Stu_Doc(struct stud_node *head)
{
struct stud_node *s;
s=head;
while(s!=NULL){
printf("%d %s %d\n",&s->num,s->name,s->score);
s=s->next;}
}
2013年01月03日 14点01分
1
@richard122
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct stud_node{
int num;
char name[20];
int score;
struct stud_node *next;
};
struct stud_node *Creat_Stu_Doc();
struct stud_node *DeleteDoc(struct stud_node *head,int min_score);
void Ptrint_Stu_Doc(struct stud_node *head);
void main()
{
struct stud_node *head;
int min_score;
head=Creat_Stu_Doc();
scanf("%d",&min_score);
head=DeleteDoc(head,min_score);
Ptrint_Stu_Doc(head);
}
struct stud_node *Creat_Stu_Doc()
{
struct stud_node *p , *tail , *head;
int num , score;
char name[20];
tail=head=NULL;
scanf("%d",&num);
while(num!=0){
scanf("%s%d",name,&score);
p=(struct stud_node*)malloc(sizeof(struct stud_node));
p->num=num;
p->score=score;
strcpy(p->name,name);
if(head==NULL)
head=p;
else
tail->next=p;
tail=p;
scanf("%d",&num);
p->next=NULL;}
return head;
}
struct stud_node *DeleteDoc(struct stud_node *head,int min_score)
{
struct stud_node *str1,*str2,*str;
str1=head;
while(str1->score<min_score)
str1=str1->next;
str=str1;
while(str1!=NULL){
str2=str1->next;
if(str2==NULL)
break;
if(str2->score<min_score){
str1->next=str2->next;
free(str2);}
str1=str1->next;}
return str;
}
void Ptrint_Stu_Doc(struct stud_node *head)
{
struct stud_node *s;
s=head;
while(s!=NULL){
printf("%d %s %d\n",&s->num,s->name,s->score);
s=s->next;}
}

