Escolar Documentos
Profissional Documentos
Cultura Documentos
#include<conio.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<process.h>
void detail()
cout<<”From”<<endl;
gets(to);
cout<<”To”<<endl;
gets(from);
class railways
{
char station[60];
float fare;
public:
void ad_data()
gets(station);
cin>>distance;
fare=fabs((a-b))*c;
{
return distance;
char*station_v()
return station;
void modify()
gets(station);
cin>>distance;
} tr;
void main()
clrscr();
char station_searched[30];
while(1)
{
clrscr();
cout<<”~”;
cout<<”~”;
cin>>choice;
while(choice==1)
tr.ad_data();
of1.write((char*)&tr, sizeof(tr));
of1.close();
break;
while(choice==2)
detail();
while(of1)
of1.read((char*)&tr, sizeof(tr));
if(0==strcmp(from, tr.station_v()))
d1=tr.dist();
If(0==strcmp(to, tr.station_v()))
d2= tr.dist();
If(d1&&d2)
{
getch();
break;
If(of1.eof())
getch();
of1.close();
break;
If(choice==3)
cin>>per_km;
if(choice==4)
{
gets(station_searched);
while(f1)
f1.read((char*)&tr, sizeof(tr));
long pos=f1.tellg();
if(0==strcmp(station_searched, tr.station_v()))
f1.seekg((~1*sizeof(tr), ios::cur));
tr.modify();
f1.close();
f1.seekp(pos, ios::beg);
f1.write((char*)&tr, sizeof(tr));
cout<<”record modified”;
f1.close();
break;
}
else if(f1.eof())
getch();
if(choice==5)
getch();
exit(0);
if(choice!=1&&choice!=2&&choice!=3&&choice!=4&&choice!=5)
getch();
exit(0);
}
getch();