Разработка программы для создания и работы с двусвязным списком, состоящим из структур (Структура содержит фамилию и 4 оценки), страница 4

                                 do{     //schitat ocenku 3 do zapyatoy

                                             fil.get(a);

                                             if (a!=',') o=(a-48);

                                 }while (a!=',');

                                 p->ocenka3=o;

                                 do{     //schitat ocenku 4 do konca stroki ili faila

                                             fil.get(a);

                                             if (a!=char(10)&&(a!=char(-1))) o=(a-48);

                                 }while ((a!=char(10))&&(a!=char(-1)));

                                 p->ocenka4=o;

                                 num++;

                                 p->prev=pred;            //sozdanie spiska

                                 if (pred!=NULL)

                                             pred->next=p;

                                 else

                                             headd=p;

                                 pred=p;

                     }

          fil.close();            //zakrit fail

          }

          tail=p;

          tail->next=NULL;

if (scr==0) screen();

return 0;

}

int screen()               //vivod spiska na ekran

{

spis *p;

ShowWindow(Menu6);

head();                      //vivesti zagolovok tablici

int list=0;

p=headd;

int j=0;

do

          {

          if (((j+1) % 20)==0)    //vivod 20 strok na ekran

                     {               //esli 20 strok vivedeno

                     list=0;         //to ochistit ekran zhdat nazhatiya klavishi

                     gotoxy(35,23);

                     cprintf("%s","Press any key");

                     getch();

                     ShowWindow(Menu3);

                     head();

                     }

          gotoxy(1,list+3);      //vivod informacii ob studente na ekran

          cprintf("%d",j+1);

          gotoxy(4,list+3);

          cprintf("%s",p->fam);

          gotoxy(36,list+3);

          cprintf("%d",p->ocenka1);

          gotoxy(46,list+3);

          cprintf("%d",p->ocenka2);

          gotoxy(56,list+3);

          cprintf("%d",p->ocenka3);

          gotoxy(66,list+3);

          cprintf("%d",p->ocenka4);

          cprintf("\n");

          list++;                //schetchik strok

          p=p->next;

          j++;

          }

while (p!=NULL);               //poka ne konchitsa spisok

gotoxy(35,23);

cprintf("%s","Press any key");

getch();

return 0;

}

int add()                       //dobavlenie studenta v konec spiska i v fail

{

char fam[20];

char o1[1],o2[1],o3[1],o4[1];

int oc1,oc2,oc3,oc4;

fileopen(); //vizov proceduri formirovaniya spiska

ShowWindow(Menu4);              //vivesti okno

gotoxy(1,2);                    //vvod polzovatelem informacii

cprintf("%s","Vvedite familyu studenta ");

scanf("%s",fam);

cprintf("%s","Vvedite ocenku po pervomu predmetu ");

oc1=0;

while ((oc1<=0) || (oc1>5))

{cin>>oc1;

if ((oc1<=0)||(oc1>5))

          {

          cprintf("%s","Oshibka vvoda,vvedite zanovo " );

          cin.clear();

          cin.seekg(0);

          }

}

cprintf("%s","Vvedite ocenku po vtoromu predmetu ");

oc2=0;

while ((oc2<=0) || (oc2>5))

{cin>>oc2;

if ((oc2<=0)||(oc2>5))

          {

          cprintf("%s","Oshibka vvoda,vvedite zanovo " );

          cin.clear();

          cin.seekg(0);

          }

}

cprintf("%s","Vvedite ocenku po tretemu predmetu ");

oc3=0;

while ((oc3<=0) || (oc3>5))

{cin>>oc3;

if ((oc3<=0)||(oc3>5))

          {

          cprintf("%s","Oshibka vvoda,vvedite zanovo " );

          cin.clear();

          cin.seekg(0);

          }

}

cprintf("%s","Vvedite ocenku po chetvertomu predmetu ");

oc4=0;

while ((oc4<=0) || (oc4>5))

{cin>>oc4;

if ((oc4<=0)||(oc4>5))

          {

          cprintf("%s","Oshibka vvoda,vvedite zanovo " );

          cin.clear();

          cin.seekg(0);

          }

}

spis *pn,*p2;

pn=(spis *)malloc(sizeof(spis));

FILE* f=fopen("exam.txt","a");  //otkrite fayla dla dozapisi

for (int q=0;q<20;q++)                    //i sozdanie novoy structuri

          pn->fam[q]=fam[q];

fputs("\n",f);                  //zapis vvedennoy informacii v fail

fputs(fam,f);

fputs(",",f);

pn->ocenka1=oc1;

itoa(oc1,o1,10);

fputs(o1,f);

fputs(",",f);

pn->ocenka2=oc2;

itoa(oc2,o2,10);

fputs(o2,f);

fputs(",",f);

pn->ocenka3=oc3;

itoa(oc3,o3,10);

fputs(o3,f);

fputs(",",f);

pn->ocenka4=oc4;

itoa(oc4,o4,10);

fputs(o4,f);

fclose(f);                      //zakritie faila

p2=tail;                                //dobavlenie strukturi v konec spiska

pn->prev=p2;

pn->next=NULL;

p2->next=pn;

tail=pn;

cprintf("%s","DOBAVLENO!");