-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery.cpp
More file actions
137 lines (132 loc) · 4.08 KB
/
query.cpp
File metadata and controls
137 lines (132 loc) · 4.08 KB
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
#include <type.h>
int findBiggestBlockByInhab (void *){
system ("cls");
cout << "------- Finding the block with the highest number of inhabitans -----\n";
if (root == NULL) {
cout<< "Tree does not exist \n";
pause();
return 0;
}
Block *pB = root->blockarray;
int x = 0,y = 0;
for (int i=0; i < root->blockCount; i++) {
Room **rpAr = pB[i].pRoomArray;
for (int j =0; j< pB[i].countRoom ; j++) {
Inhabitant *pI = rpAr[j]->firstInhab;
while (pI != NULL) {
pI = pI->nextInhab;
x++;
}
}
if(x>y)
y = x;
x = 0;
}
for (int i = 0; i < root->blockCount; i++){
Room **rpAr = pB[i].pRoomArray;
for (int j = 0; j < pB[i].countRoom; j++){
Inhabitant *pI = rpAr[j]->firstInhab;
while (pI != NULL){
x++;
pI = pI->nextInhab;
}
}
if(x == y)
cout << "\nBlock: "<<pB[i].Numblock<<" have the highest number of inhabitant"<<endl;
x = 0;
}
pause();
return 1;
}
int findRoomForInfor (void *){
system ("cls");
cout << "___Finding information by number room ____\n";
if (root == NULL) {
cout<< "Tree does not exist \n";
pause();
return 0;
}
int x = 0;
cout << "Enter number of room for finding information(1 - 200): ";
cin >> x;
bool ok = true;
Block *bAr = root->blockarray;
for (int i=0; i < root->blockCount; i++) {
Room **rpAr = bAr[i].pRoomArray;
for (int j =0; j< bAr[i].countRoom ; j++) {
if(rpAr[j]->NumberRoom == x){
ok = false;
cout <<"\n\tNumber of room: "<<rpAr[j]->NumberRoom <<" Kilkist lizok: "<<rpAr[j]->KilkistLizok << " Square: "<<rpAr[j]->Square<<endl;
}
}
}
if(ok == true){
cout << "\n No number was found for this room\n";
}
pause();
return 1;
}
int findInhabByName (void *){
system ("cls");
cout << "___Finding information about inhbitant by his name ____\n";
if (root == NULL) {
cout<< "Tree does not exist \n";
pause();
return 0;
}
string s;
cout << "Enter name for finding information by this name: ";
getline(cin,s);
bool ok = true;
Block *bAr = root->blockarray;
for (int i=0; i < root->blockCount; i++) {
Room **rpAr = bAr[i].pRoomArray;
for (int j =0; j< bAr[i].countRoom ; j++) {
Inhabitant *pI = rpAr[j]->firstInhab;
while (pI != NULL) {
if(s == pI->name){
ok = false;
cout << "\t\t\tName: "<<pI->name <<" Year to room: "<<pI->YeartoRoom<<" Facult: "<<pI->Facult<<endl;
}
pI = pI->nextInhab;
}
}
}
if(ok == true){
cout << "\n Nothing was found by that name\n";
}
pause();
return 1;
}
int findInhabByYear (void *){
system ("cls");
cout << "___Finding information about inhbitant by year to room ____\n";
if (root == NULL) {
cout<< "Tree does not exist \n";
pause();
return 0;
}
int x = 0;
cout << "Enter the year to find information about the occupants of this year : ";
cin >> x;
bool ok = true;
Block *bAr = root->blockarray;
for (int i=0; i < root->blockCount; i++) {
Room **rpAr = bAr[i].pRoomArray;
for (int j =0; j< bAr[i].countRoom ; j++) {
Inhabitant *pI = rpAr[j]->firstInhab;
while (pI != NULL) {
if(pI->YeartoRoom == x){
ok = false;
cout << "\t\t\tName: "<<pI->name <<" Year to room: "<<pI->YeartoRoom<<" Facult: "<<pI->Facult<<endl;
}
pI = pI->nextInhab;
}
}
}
if(ok == true){
cout << "\n No residents were found this year \n";
}
pause();
return 1;
}