Сведения о расходе горючего на автобазах города
Рефераты >> Программирование и компьютеры >> Сведения о расходе горючего на автобазах города

void spisok()

{

nach=new predpry;

nach->next=0;

strcpy(nach->nazva,"fik");

nach->valprod =0;

nach->kolrab =0;

do

{

clrscr();

cout << "VID RABOT S ODNOSV'AZNIM SPISKOM:\n";

cout << "1) SOZDANIE SPISKA\n";

cout << "2) DOPOLNENIE SPISKA\n";

cout << "3) KORREKTIROVKA ZAPISEY\n";

cout << "4) UDALENIE ZAPISEY\n";

cout << "5) PECHAT' SPISKA\n";

cout << "6) SOHRANENIE SPISKA\n";

cout << "7) OCHISTKA SPISKA\n";

cout << "8) VOSSOZDANIE SPISKA\n";

cout << "9) VOZVRAT V OSNOVNOE MENU\n";

cout << "VASH VIBOR: ";

cin >> vibor;

clrscr();

switch (vibor)

{

case '1':

clrscr();

sozd(nach);

pause();

break;

case '2':

clrscr();

vstavka(nach);

pause();

break;

case '3':

clrscr();

korekt(nach);

pause();

break;

case '4':

clrscr();

udalen(nach);

pause();

break;

case '5':

clrscr();

prints(nach);

pause();

break;

case '6':

clrscr();

soxran(nach);

pause();

break;

case '7':

clrscr();

ochistka(nach);

pause();

break;

case '8':

clrscr();

vossosdanie(nach);

pause();

break;

}

} while (vibor!='9');

}

////////////////////////////////////////////////////////////////////

void sozd(predpry* nach)

{

clrscr();

do

{

//clrscr();

vstavka(nach);

cout<<"\nPRODOLGIT' VVOD ?(Y/N) ";

cin>>otv;

} while ((otv!='N')&&(otv!='n'));

}

//////////////////////////////////////////////////////////////////////////////

void vstavka(predpry* nach)

{

predpry* nov; predpry* tek1;

int b;

tek=nach->next;

tek1=nach;

b=1;

nov=new predpry;

cout<<"\nVVEDITE NOVIE DANNYE PO Avtobazam?\n";

cout << "\nAvtobaza (NE BOLEE 15 SIMVOLOV)- ";

cin >> nov->nazva;

while ((tek!=0) && b)

{

if ( !strcmp(tek->nazva,nov->nazva))

{

cout<< "Tacaia familia uje sozdano\n";

b=0;

return;

}

else

{

tek1=tek;

tek=tek->next;

}

}

cout << "Izrashodovano topliva - ";

cin >> nov->valprod;

cout << "Kolichestvo Avto - ";

cin >> nov->kolrab;

nov->proizv=nov->valprod/nov->kolrab;

cout << "Sredniy rashod: ";

cout << nov->proizv;

nov->next=tek1->next;

tek1->next=nov;

}

////////////////////////////////////////////////////////////////////////////

void korekt(predpry* nach)

{

clrscr();

char k[15];

int b=1;

cout<<"\nVvedite corectiruemuy Avtobazy ";

cin>>k;

tek=nach->next;

while ((tek!=0) && b )

{

if(!strcmp(tek->nazva,k))

b=0;

else

tek=tek->next;

}

if (b==0)

{

if (!strcmp(tek->nazva,k) )

{

cout<<"\nVVEDITE NOVIE DANNYE PO AVTOBAZAM?)\n";

cout << "AVTOBAZA (NE BOLEE 15 SIMVOLOV) - ";

cin >> tek->nazva;

cout << "\nIZRASHODOVANO TOPLIVA - ";

cout << tek->valprod;

cout << "\nIZMENIT' (Y/N) ";

cin >> otv;

if ((otv!='N')&&(otv!='n'))

{

cout << "\nNOVIY KOLICHESTVO IZRASHODOVANOGO TOPLIVA - ";

cin >> tek->valprod;

}

cout << "\nkOLICHESTVO AVTO - ";

cout << tek->kolrab;

cout << "\nIZMENIT' (Y/N) ";

cin >> otv;

if ((otv!='N')&&(otv!='n'))

{

cout << "\nNOVOE KOLICHESTVO IZRASHODOVANOGO TOPLIVA - ";

cin >> tek->kolrab;

}

tek->proizv=tek->valprod/tek->kolrab;

cout << "\nVsego vidano: ";

cout << tek->proizv;

cout << "\n";

}

}

else

{

cout<<"Familia " << k << " NE NAIDENO!\n";

return;

}

}

//////////////////////////////////////////////////////////////////////////////////

void udalen(predpry* nach)

{

predpry* tek1;

clrscr();

int b=1;

char isk[15];

cout<<"\nVVEDITE NAZVANIE ISKLUCHAEMOGY AVTOBAZI\n";

cin>>isk;

tek=nach->next;

tek1=nach;

if(tek==0)

{

cout << "\nSPISOK PUST, UDALAT' NECHEGO!";

return;

}

while ((tek!=0) && b )

{

if(!strcmp(tek->nazva,isk))

{

tek1=tek;

b=0;

}

else tek=tek->next;

}

if (b==0)

{if (!strcmp(tek->nazva,isk) )

{

tek1->next=tek->next;

delete tek;

}

}

else

cout<<"\nFamilia NE NAIDENA!\n";

return;

}

///////////////////////////////////////////////////////////////////////////////////

void prints(predpry* nach)

{

float svalprod=0;

int skolrab=0;

float sproizv=0;

int i=1;

tek=nach->next;

if (tek==0)

{

cout << "\nSPISOK PUST!\n";

return;

}

cout<<"--------------------------------------------------------------\n";

cout<<"| N | AVTOBAZA |IZRASHODOV |KOLICHESTVO| SREDNIY |\n";

cout<<"|p/p| | TOPLIVA | AVTO | RASHOD |\n";

cout<<"--------------------------------------------------------------\n";

while (tek!=0)

{

cout<<"|";

cout<<setw(3)<<(i++)<<"|";

cout.setf(ios::left);

cout<<setw(21)<<tek->nazva<<"|";

cout.setf(ios::fixed);

cout.setf(ios::right);

cout<<setprecision(2);

cout<<setw(11)<<tek->valprod<<"|";

svalprod+=tek->valprod;

cout<<setw(11)<<tek->kolrab<<"|";

skolrab+=tek->kolrab;

cout<<setw(10)<<tek->proizv<<"|"<<endl;

sproizv+=tek->proizv;

tek=tek->next;

}

cout<<"--------------------------------------------------------------\n";

cout<<"| | ITOGO|";

cout<<setw(11)<<svalprod<<"|";

cout<<setw(11)<<skolrab<<"|";

cout<<setw(10)<<sproizv<<"|"<<endl;

cout<<"--------------------------------------------------------------\n";


Страница: