C语言实验报告参考答案 下载本文

printf(\

printf(\ while(p!=NULL) { i++;

printf(\

|\\n\ p=p->next; }

printf(\ }

STUDENT *delete(STUDENT *h) {

STUDENT *p,*q; char s[11]; clrscr();

printf(\ scanf(\ q=p=h;

while(strcmp(p->no,s)&&p!=NULL) { q=p; p=p->next; }

if(p==NULL)

printf(\ else {

printf(\ printf(\

printf(\ printf(\

|\\n\

printf(\ getch(); if(p==h) h=p->next; else

q->next=p->next; free(p);

printf(\ }

return(h); }

STUDENT *searchno(STUDENT *h) {

STUDENT *p,*q; char s[11]; clrscr();

printf(\ scanf(\ q=p=h;

while(strcmp(p->no,s)&&p!=NULL) { q=p; p=p->next; }

if(p==NULL)

printf(\ else {

printf(\

printf(\ printf(\

printf(\ printf(\

|\\n\

printf(\ getch(); }

return(h); }

void search(STUDENT *h) {

STUDENT *p; char s[15]; clrscr();

printf(\ scanf(\ p=h;

while(strcmp(p->name,s)&&p!=NULL) p=p->next; if(p==NULL)

printf(\ else {

printf(\

printf(\ printf(\

printf(\ printf(\

|\\n\

printf(\ } }

STUDENT *insert(STUDENT *h) {

STUDENT *p,*q,*info; char s[11]; int s1,i;

printf(\ scanf(\

printf(\

info=(STUDENT *)malloc(sizeof(STUDENT)); if(!info) {

printf(\ return NULL; }

inputs(\ inputs(\ printf(\ s1=0;

for(i=0;i

printf(\ if(i==1)

printf(\ scanf(\

if(info->score[i]>100||info->score[i]<0) printf(\

}while(info->score[i]>100||info->score[i]<0); s1=s1+info->score[i]; }

info->sum=s1; info->order=0; info->next=NULL; p=h; q=h;

while(strcmp(p->no,s)&&p!=NULL) { q=p; p=p->next; }

if(p==NULL) if(p==h)

h=info; else

q->next=info; else if(p==h) {

info->next=p; h=info; } else {

info->next=p; q->next=info; }

printf(\ return(h); }

/* SAVE*/

void save(STUDENT *h) {

FILE *fp; STUDENT *p; char outfile[10];

printf(\ scanf(\

if((fp=fopen(outfile,\ {

printf(\ exit(1); }

printf(\ p=h;

while(p!=NULL) {

fwrite(p,sizeof(STUDENT),1,fp); p=p->next; }

fclose(fp);

printf(\ }

STUDENT *load() {

STUDENT *p,*q,*h=NULL; FILE *fp; char infile[10];

printf(\

if((fp=fopen(infile,\ {

printf(\ exit(1); }

printf(\ p=(STUDENT *)malloc(sizeof(STUDENT)); if(!p) {

printf(\ return h; } h=p;

while(!feof(fp)) {

if(1!=fread(p,sizeof(STUDENT),1,fp)) break;

p->next=(STUDENT *)malloc(sizeof(STUDENT)); if(!p->next) {

printf(\ return h; } q=p; p=p->next; }

q->next=NULL; fclose(fp);

printf(\ return h; } /*sort*/

STUDENT *sort(STUDENT *h) { int i=0;

STUDENT *p,*q,*t,*h1; h1=h->next; h->next=NULL; while(h1!=NULL) { t=h1; h1=h1->next; p=h; q=h;

while(t->sumsum&&p!=NULL) {