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

Menu6={1,1,79,24,0,"Prosmotr soiska",BLACK,CYAN,0,NULL};

int num=0;                      //kol-vo studentov

int scr=0;

struct spis *headd, *tail;

main()

{

union REGS regs;

regs.h.ah=1;

regs.h.ch=32;

int86(VIDEO,&regs,&regs);           //kursor nevidim

ShowWindow(Menu);

ShowWindow(Menu1);

Navig(Menu1);

}

//narisovat menu s okno

int ShowWindow(Menu_W Menu)

{window(Menu.LtRow,Menu.LtCol,Menu.LtRow+Menu.Width,Menu.LtCol+Menu.Height);

textcolor(Menu.SimvolColor);

textbackground(Menu.Background);

clrscr();

gotoxy((1+Menu.Width/2-strlen(Menu.Titl)/2),1);

cprintf("%s",Menu.Titl);

int i;

if (Menu.Text!=NULL)

          {gotoxy(2,2);

          for (i=0;i<Menu.n;i++)

                     {cprintf("%s",Menu.Text[i]);

                     gotoxy(2,2+i+1);

                     }

          }

return 0;

}

//otobrazit aktivniy punkt menu

int Select_tema(Menu_W Menu,int kod)

{gotoxy(2,kod+2);

textcolor(Menu.SimvolColor);

textbackground(abs(Menu.Background-10));

cprintf("%s",Menu.Text[kod]);

return 0;

}

//otobrazit neaktivniy punkt menu

int tema(Menu_W Menu,int kod)

{gotoxy(2,kod+2);

textcolor(Menu.SimvolColor);

textbackground(Menu.Background);

cprintf("%s",Menu.Text[kod]);

return 0;

}

//peredvizhenie po menu

int Navig (Menu_W Menu)

{

//ustanovit nomer aktivnogo punkta (kod), maximalno

//vozmozhniy nomer punkta (kodmax)

int kod=0,kodmax=Menu.n;

//otobrazit aktivniy punkt menu

Select_tema(Menu,kod);

union KEY {int i;

           char ch[2];

           }press;

int flag=1;

do {

          press.i=bioskey(0);     //priev s ozhidaniev

          if (press.ch[0])            //nazhata ASCII-klavisha

          {switch (press.ch[0])

                     {case 27: flag=0;break;

                     case 13: {dile(kod);break;}//perehod na deystviya

                     }

          }

          else                             //nazhata  specialnaya klavisha

          {switch(press.ch[1])

                     {                      //peredvizhenie vverh po menu

                     case 72:{tema(Menu,kod);

                                 kod-=1;STOP;

                                 Select_tema(Menu,kod);;

                                 break;

                                 }

                                             //peredvizhenie vniz po menu

                      case 80:{tema(Menu,kod);

                                 kod+=1;STOP;

                                 Select_tema(Menu,kod);;

                                 break;

                                 }

                      }

          }

   } while (flag==1);

   return 0;

}

int dile(int kod)               //procedura vibora deystviya

{

switch (kod)                    //v zavisimosti ot togo kakoy punkt vibran

          {

          case 0:{scr=0;

                     fileopen();    //otkrit fail, sozdat spisok i vivesti ego

                     break;

                     }

          case 1:{scr=1;

                     add();         //dobavit studenta

                     break;

                 }

          case 2:{scr=1;

                     remove();      //udalit neuspevayushego studenta

                     break;

                 }

          }

ShowWindow(Menu);               //otobrazit glavnoe menu

ShowWindow(Menu1);

return 0;

}

int fileopen()                  //otkritie faila i vivod na ekran ego soderzhimogo v spisok

{

ifstream fil;                   //peremennaya fail

ShowWindow(Menu3);              //pokazat okno

spis *p,*pred;

pred=NULL;

char curfam[20];

int o=0;

int i=0;

num=0;

char a=NULL;

fil.open("exam.txt");                       //otkritie faila

if (fil){

          while (!fil.eof())      //poka ne konec faila

                     {

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

                                 for (int q=0;q<20;q++)

                                       {

                                             p->fam[q]=NULL;

                                             curfam[q]=NULL;

                                       }

                                 do{     //schitat familiyu do zapatoy

                                             fil.get(a);

                                             if (a!=',') curfam[i]=a;

                                             i++;

                                 }while (a!=',');

                                 for (int qq=0;qq<i-1;qq++)

                                             p->fam[qq]=curfam[qq];

                                 i=0;

                                 do{     //schitat ocenku 1 do zapyatoy

                                             fil.get(a);

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

                                 }while (a!=',');

                                 p->ocenka1=o;

                                 do{     //schitat ocenku 2 do zapyatoy

                                             fil.get(a);

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

                                 }while (a!=',');

                                 p->ocenka2=o;