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
| #include "stdafx.h"
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
struct NOTE
{
char name[30];
char surname[30];
double No;
int Date[3];
};
void MyOut(ostream& out, NOTE *NoteStream)
{
cout << setiosflags(ios::left) << fixed << setprecision(0) << NoteStream[0].name << " " << setw(15);
cout << setfill('.') << NoteStream[0].surname << setw(10);
cout << NoteStream[0].No << " " << NoteStream[0].Date[0] << " " << NoteStream[0].Date[1] << " " << NoteStream[0].Date[2] << endl;
}
void getSurname(string Surname,NOTE *Notestream)
{
int I=-2;
for (int i = 0; i < 3; i++){
if (Surname == Notestream[i].surname)
{
I = i;
}
else { I = -1; continue; }
}
cout << I;
if (I > 0)
{
cout << " " << Notestream[I].surname << " " << Notestream[I].name;
cout << "\t" << Notestream[I].Date[0] << " " << Notestream[I].Date[1] << " " << Notestream[I].Date[2] << endl;
}
}
int main()
{
setlocale(0, "");
char buff[100];
char buff1[100];
NOTE First,Second,Third;
string Surname;
First = { "Ivan", "Ohlobystin", 89261237771, { 11, 25, 2014 } };
Second = { "Roy", "Jones", 89265607930, { 12, 31, 2013 } };
Third = { "Lara", "Kroft", 8926312215, { 10, 26, 2011 } };
cout << "Введите фамилию" << endl;
cin >> Surname;
getSurname(Surname, Second.surname);
ofstream fout("cpp.txt",ios::binary);
ifstream fin("cpp.txt");
fout << setiosflags(ios::left) << fixed << setprecision(0) << Second.name << " " << setw(15) << setfill('.') << Second.surname << setw(10) << Second.No << " " << Second.Date[0] << " " << Second.Date[1] << " " << Second.Date[2] << endl;
fin.getline(buff, 100);
cout << buff << "\n\n";
cout << "COUT" << endl;
MyOut(cout, &First);
MyOut(cout, &Second);
MyOut(cout, &Third);
cout << "FOUT" << endl;
MyOut(fout, &First);
MyOut(fout, &Second);
MyOut(fout, &Third);
fout.close();
cin.get();
cin.get();
return 0;
} |