-
Notifications
You must be signed in to change notification settings - Fork 0
/
ATP1.CPP
81 lines (78 loc) · 1.08 KB
/
ATP1.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
class idc
{ private:
int i;
public:
idc()
{
}
idc(int a)
{ i=a;
}
int ret_id()
{ return i;
}
};
class pnrc
{ private:
int pn;
public:
pnrc()
{
}
pnrc(int a)
{ pn=a;
}
int ret_pnr()
{ return pn;
}
};
class tic
{ private:
char tname[50],s_st[4],e_st[4];
int pnr,id_c;
void enter_pnr()
{ ofstream f("pnr.dat",ios::binary|ios::app);
pnrc ob(pnr);
f.write((char *)&ob,sizeof(ob));
f.close();
}
void create_pnr();
public:
tic(int a)
{ id_c=a;
}
void create()
{ gets(tname);
gets(s_st);
gets(e_st);
create_pnr();
}
int ret_pnr()
{ return pnr;
}
};
void tic::create_pnr()
{ ifstream f("pnr.dat",ios::binary);
pnrc ob;
int flag;
do
{ flag=0;
randomize();
pnr=random(10000);
while(f.read((char *)&ob,sizeof(ob)))
{ if(ob.ret_pnr()==pnr)
{ flag=1;
break;
}
}
}while(flag==1 || pnr<=999);
f.close();
enter_pnr();
}
void main()
{
}