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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
| #include <iostream>
#include <locale.h>
#include <stdlib.h>
#include <windows.h>
#include <fstream>
using namespace std;
struct Vlasnik
{
char prizvishe[20];
char imya[20];
char kraina[20];
char oblast[20];
char misto[20];
};
void add(Vlasnik *vlas,char n)
{
for(int i(0);i<n;i++)
{
cout<<"Введите Фамилию :";
cin>>vlas[i].prizvishe;
cout<<"Введите Имя :";
cin>>vlas[i].imya;
cout<<"Введите страну:";
cin>>vlas[i].kraina;
cout<<"Введите область:";
cin>>vlas[i].oblast;
cout<<"Введите город:";
cin>>vlas[i].misto;
cout<<"================================================================="<<endl;
}
}
void show(Vlasnik *vlas, char n)
{
for(int i(0); i<n; i++)
{
cout<<i+1<<") Описание владельца:"<<endl;
cout<<"Введите Фамилию :";
cin>>vlas[i].prizvishe;
cout<<"Введите Имя :";
cin>>vlas[i].imya;
cout<<"Введите страну:";
cin>>vlas[i].kraina;
cout<<"Введите область:";
cin>>vlas[i].oblast;
cout<<"Введите город:";
cin>>vlas[i].misto;
cout<<"=================================================================="<<endl;
}
}
void search(Vlasnik *vlas, int n, string boes)
{
for(int i=0; i<n; i++)
{
if(vlas[i].prizvishe==boes){
cout<<i+1<<") Описание владельца:"<<endl;
cout<<"Введите Фамилию :";
cin>>vlas[i].prizvishe;
cout<<"Введите имя :";
cin>>vlas[i].imya;
cout<<"Введите страну:";
cin>>vlas[i].kraina;
cout<<"Введите область:";
cin>>vlas[i].oblast;
cout<<"Введите город:";
cin>>vlas[i].misto;
cout<<"=================================================================="<<endl;
}
if(vlas[i].imya==boes){
cout<<i+1<<") Описание владельца:"<<endl;
cout<<"Введите фамилию :";
cin>>vlas[i].prizvishe;
cout<<"Введите имя :";
cin>>vlas[i].imya;
cout<<"Введите страну:";
cin>>vlas[i].kraina;
cout<<"Введите область:";
cin>>vlas[i].oblast;
cout<<"Введите город:";
cin>>vlas[i].misto;
cout<<"=================================================================="<<endl;
}if(vlas[i].kraina==boes){
cout<<i+1<<") Описание владельца:"<<endl;
cout<<"Введите фамилию :";
cin>>vlas[i].prizvishe;
cout<<"Введите имя :";
cin>>vlas[i].imya;
cout<<"Введите страну:";
cin>>vlas[i].kraina;
cout<<"Введите область:";
cin>>vlas[i].oblast;
cout<<"Введите город:";
cin>>vlas[i].misto;
cout<<"=================================================================="<<endl;
}if(vlas[i].oblast==boes){
cout<<i+1<<") Описание владельца:"<<endl;
cout<<"Введите фамилию :";
cin>>vlas[i].prizvishe;
cout<<"Введите имя :";
cin>>vlas[i].imya;
cout<<"Введите страну:";
cin>>vlas[i].kraina;
cout<<"Введите область:";
cin>>vlas[i].oblast;
cout<<"Введите город:";
cin>>vlas[i].misto;
cout<<"=================================================================="<<endl;
}if(vlas[i].misto==boes){
cout<<i+1<<") Описание владельца:"<<endl;
cout<<"Введите фамилию :";
cin>>vlas[i].prizvishe;
cout<<"Введите имя :";
cin>>vlas[i].imya;
cout<<"Введите страну:";
cin>>vlas[i].kraina;
cout<<"Введите область:";
cin>>vlas[i].oblast;
cout<<"Введите город:";
cin>>vlas[i].misto;
cout<<"=================================================================="<<endl;
}
}
}
void delet_vlas(Vlasnik *Vlas, int &n, int nom)
{
for(int i=nom-1; i<n; i++)
{
if(i==nom)
{
Vlas[i]=Vlas[i++];
}
--n;
}
}
int main()
{
SetConsoleCP (1251);
SetConsoleOutputCP (1251);
string boes;
cout<<"Введите колличество владельцев для добавление в базу данных: ";
int n;
cin>>n;
Vlasnik *Vlas= new Vlasnik[n];
int nomermenu, bc;
while(1)
{
m2:
cout<<"=================================================================="<<endl;
cout<<"Выберите пункт меню:"<<endl;
cout<<"1)Добавить данные. "<<endl;
cout<<"2)Вывести данные. "<<endl;
cout<<"3)Найти владельца по описанию. "<<endl;
cout<<"4)Записать данные в базу . "<<endl;
cout<<"5)Удалить владельца из базы. "<<endl;
cout<<"6)Очистить консоль. "<<endl;
cout<<"0)Выйти. "<<endl;
cin>>nomermenu;
system("cls");
switch(nomermenu)
{
case 1: add(Vlas, n);
break;
case 2: show(Vlas, n);
break;
case 3: m1: cout<<"1)По Фамилии?\t 2)По имени \t"
<<"3)По стране \t4)По области \t)По городу"<<endl;
cin>>bc;
switch(bc)
{
case 1: cout<<"1)Введите пожалуйста Фамилию:";
cin>>boes;
search(Vlas, n, boes);
break;
case 2: cout<<"2)Введите пожалуйста имя:";
cin>>boes;
search(Vlas, n, boes);
break;
case 3: cout<<"3)Введите пожалуйста страну:";
cin>>boes;
search(Vlas, n, boes);
break;
case 4: cout<<"5)Введите пожалуйста область:";
cin>>boes;
search(Vlas, n, boes);
break;
case 5: cout<<"5)Введите пожалуйста город:";
cin>>boes;
search(Vlas, n, boes);
break;
default: cout<<"Вы ввели не правильный вариант, повторите еще раз."<<endl; goto m1;
}
break;
case 4: cout<<"Введите номер владельца которого нужно удалить:";
int nomer;
cin>>nomer;
delet_vlas(Vlas, n, nomer);
break;
case 5: system ("cls");
break;
case 0: exit(0);
break;
default: cout<<"Не правильно введеный номер меню, повторите еще раз."<<endl; goto m2;
}
}
delete [] Vlas;
return 0;
} |