Платежная ведомость предприятияРефераты >> Программирование и компьютеры >> Платежная ведомость предприятия
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";
}
/////////////////////////////////////////////////////////////////////
void soxran(predpry* nach)
{
tek=nach->next;
if (tek==0)
{
cout<<"\nSPISOK PUST!";
return;
}
int k=0;
char fname[8];
cout << "\nVVEDITE IMY'A FAILA \n";
cin >> fname;
ofstream potok;
potok.open(fname,ios::out|ios::binary);
if(!potok)
{
cout << "\nOSHIBKA OTKRITIA FAILA!";
return;
}
while (tek!=0)
{
strcpy(buf.nazva,tek->nazva);
buf.valprod = tek->valprod;
buf.kolrab = tek->kolrab;
buf.proizv = tek->proizv;
potok.write((char*)&buf, sizeof(buf));
tek=tek->next;
k++;
}
cout << "\nSOHRANENO " << k << " ZAPISEY";
potok.close();
}
//////////////////////////////////////////////////////////////////////////////////
void vossosdanie(predpry* nach)
{
long kol;
int k=0;
char fname[8];
cout << "\nVVEDITE IMY'A FAILA \n";
cin >> fname;
fstream potok;
potok.open(fname,ios::app|ios::binary|ios::nocreate);
if(!potok)
{
cout << "\nOSHIBKA OTKRITIA FAILA!\n";
return;
}
potok.seekp(0,ios::end);
kol = potok.tellp( ) / sizeof(predpry);
potok.close();
cout << kol;
potok.open(fname,ios::in|ios::binary);
nach->next = 0;
predpry* nov;
predpry* tek1;
for(int i=0; i<kol; i++)
{
potok.read((char*)&buf, sizeof(buf));
tek=nach->next;
tek1=nach;
nov=new predpry;
strcpy(nov->nazva,buf.nazva);
nov->valprod = buf.valprod;
nov->kolrab = buf.kolrab;
nov->proizv = buf.proizv;
nov->next=tek1->next;
tek1->next=nov;
k++;
}
cout << "\nVOSSOZDANO " << k << " ZAPISEY\n";
potok.close();
}
////////////////////////////////////////////////////////////////////////////
void ochistka(predpry *nach)
{
int k=0;
tek=nach->next;
if (tek==0)
{
cout<<"\nSPISOK PUST!";
return ;
}
while (tek!=0)
{
delete tek;
tek=tek->next;
k++;
}
nach->next=0;
cout << "\nUDALENO " << k << " ELEMENTOV SPISKA";
}