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

gotoxy(1,25);

printf(\getch(); clrscr(); gotoxy(1,1);

textcolor(YELLOW);

textbackground(BLACK); gotoxy(10,2); putch(0xc9); for(i=1;i<44;i++) putch(0xcd); putch(0xbb); for(i=3;i<20;i++) {

gotoxy(10,i);putch(0xba); gotoxy(54,i);putch(0xba); }

gotoxy(10,20);putch(0xc8); for(i=1;i<44;i++) putch(0xcd); putch(0xbc);

window(11,3,53,19); clrscr();

for(i=0;i<16;i++) {

gotoxy(10,i+1);

cprintf(\}

textbackground(BLACK); window(1,1,80,25); gotoxy(10,21); do{

printf(\scanf(\c=atoi(s);

}while(c<0||c>14); return c; }

STUDENT *init() {

return NULL; }

STUDENT *create() {

int i; int s;

STUDENT *h=NULL,*info; for(;;) {

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

printf(\return NULL; }

inputs(\if(info->no[0]=='0') break; /*when the first number is 0,break*/ inputs(\printf(\s=0; /*s is sum,begins with 0*/ for(i=0;i

printf(\if(i==1)

printf(\

scanf(\/* socre[0] stores maths scores,socore[1] stores program scores*/

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

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

info->sum=s; info->order=0; info->next=h; h=info; }

return(h); }

inputs(char *prompt, char *s, int count) {

char p[255]; do{

printf(prompt); scanf(\

if(strlen(p)>count)printf(\}while(strlen(p)>count); strcpy(s,p); }

/*Print infor*/

void print(STUDENT *h) {

int i=0;

STUDENT *p; clrscr(); p=h;

printf(\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;

=