-
Notifications
You must be signed in to change notification settings - Fork 0
/
BIN.CPP
95 lines (86 loc) · 1.59 KB
/
BIN.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# include <iostream.h>
# include <math.h>
# include <conio.h>
# include<iomanip.h>
# include <string.h>
# include <stdio.h>
# include <ctype.h>
# include <stdlib.h>
struct monitor
{
char n[11];
int d,o,r;
}mon;
void main ()
{
clrscr();
FILE *f,*f1;
char s[80],s1[80];
int i,so=0;
if ((f=fopen("C:\\borlandc\\Monitor.txt","r+t"))==0)
{
cout<<"Oshibka";
return;
}
if ((f1=fopen("C:\\borlandc\\BMonitor.txt","w+b"))==0)
{
cout<<"Oshibka";
return;
}
while(fgets(s,30,f))
{
strncpy(mon.n,s,10);
mon.n[10]='\0';
mon.d=atoi(&s[10]);
mon.o=atoi(&s[13]);;
mon.r=atoi(&s[18]);;
fwrite(&mon,sizeof (mon),1,f1);
}
fclose(f);
fclose(f1);
if ((f1=fopen("C:\\borlandc\\BMonitor.txt","r+b"))==0)
{
cout<<"Oshibka";
return;
}
while(fread(&mon,sizeof (mon),1,f1))
{
puts(mon.n);
cout<<mon.d<<endl;
cout<<mon.o<<endl;
cout<<mon.r<<endl;
if (mon.r>so) so=mon.r;
}
fclose(f1);
gets(s1);
if ((f1=fopen("C:\\borlandc\\BMonitor.txt","r+b"))==0)
{
cout<<"Oshibka";
return;
}
while(fread(&mon,sizeof (mon),1,f1))
{
i=0;
while(mon.n[i]!=' ')
i++;
mon.n[i]='\0';
if (strcmp(s1,mon.n)==0)
{
puts(mon.n);
cout<<mon.d<<endl;
cout<<mon.o<<endl;
cout<<mon.r<<endl;
}
}
fclose(f1);
if ((f1=fopen("C:\\borlandc\\BMonitor.txt","r+b"))==0)
{
cout<<"Oshibka";
return;
}
while(fread(&mon,sizeof (mon),1,f1))
if (so==mon.r)
puts(mon.n);
fclose(f1);
getch();
}