-
Notifications
You must be signed in to change notification settings - Fork 0
/
LIBSEARC.CPP
191 lines (190 loc) · 3.54 KB
/
LIBSEARC.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
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
#include<iostream.h>
#include<conio.h>
struct book {
char name[20];
char writer[20];
char nasher[20];
char gheymet[20];
char salechap[20];
}b[100];
//////////////////////////////
int menu();
void insert();
void search(int);
void booksearch();
void writersearch();
void salsearch();
int i1;
//////////////////////////////
int menu()
{
int n;
clrscr();
cout<<"1.Enter Data";
cout<<"\n2.Search name book";
cout<<"\n3.Search writer book";
cout<<"\n4.search Sale enteshar";
cout<<"\n5.Exit Library";
cout<<"\n\nEnter 1..5: ";
do {
gotoxy(15,7);
cin>>n;
} while (n>5);
return n;
}
///////////////////////////////////////
void main()
{ int n;
while (1) {
n=menu();
if (n==1) insert();
else search(n);
if (n==5) break;
}
}
///////////////////////////////////////
void insert()
{
int i,y=4,n;
clrscr();
cout<<"Enter number of book: ";
cin>>n;
clrscr();
gotoxy(1,1);
cout<<"Name book writer name Nasher gheymat sale enteshar";
gotoxy(1,2);
for (i=1;i<80;cout<<"-",i++);
for (i1=0;i1<n;i1++,y++) {
gotoxy(1,y);
cin>>b[i1].name;
gotoxy(15,y);
cin>>b[i1].writer;
gotoxy(30,y);
cin>>b[i1].nasher;
gotoxy(45,y);
cin>>b[i1].gheymet;
gotoxy(60,y);
cin>>b[i1].salechap;
}
getch();
}
///////////////////////////////////////
void search(int n)
{
switch (n) {
case 2: booksearch();
break;
case 3:writersearch();
break;
case 4:salsearch();
break;
}
}
/////////////////////////////////////////
void booksearch()
{
char t[20],ch;
clrscr();
cout<<"Enter your book: ";
gotoxy(1,2);
ch=getch();
int i=0;
while (ch!=13) {
t[i++]=ch;
t[i]='\0';
clrscr();
gotoxy(1,1);
cout<<"Enter your book: ";
cout<<t;
gotoxy(1,5);
cout<<"Name book writer name Nasher gheymat sale enteshar";
gotoxy(1,6);
for (int i2=1;i2<=80;cout<<"-",i2++);
for (int j=0;j<i1;j++){
int sw=0;
for (int k=0;k<i;k++)
if (t[k]!=b[j].name[k])
sw=1;
if (sw==0) {
cout<<b[j].name<<"\t\t";
cout<<b[j].writer<<"\t\t";
cout<<b[j].nasher<<"\t\t";
cout<<b[j].nasher<<"\t\t";
cout<<b[j].salechap<<"\n\n";
}
}
ch=getch();
}
}
/////////////////////////////////////////
void writersearch()
{
char t[20],ch;
clrscr();
cout<<"Enter your writer: ";
gotoxy(1,2);
ch=getch();
int i=0;
while (ch!=13) {
t[i++]=ch;
t[i]='\0';
clrscr();
gotoxy(1,1);
cout<<"Enter your writer: ";
cout<<t;
gotoxy(1,5);
cout<<"Name book writer name Nasher gheymat sale enteshar";
gotoxy(1,6);
for (int i2=1;i2<=80;cout<<"-",i2++);
for (int j=0;j<i1;j++){
int sw=0;
for (int k=0;k<i;k++)
if (t[k]!=b[j].writer[k])
sw=1;
if (sw==0) {
cout<<b[j].name<<"\t\t";
cout<<b[j].writer<<"\t\t";
cout<<b[j].nasher<<"\t\t";
cout<<b[j].nasher<<"\t\t";
cout<<b[j].salechap<<"\n\n";
}
}
ch=getch();
}
}
/////////////////////////////////////////
void salsearch()
{
char t[20],ch;
clrscr();
cout<<"Enter your sal: ";
gotoxy(1,2);
ch=getch();
int i=0;
while (ch!=13) {
t[i++]=ch;
t[i]='\0';
clrscr();
gotoxy(1,1);
cout<<"Enter your sal: ";
cout<<t;
gotoxy(1,5);
cout<<"Name book writer name Nasher gheymat sale enteshar";
gotoxy(1,6);
for (int i2=1;i2<=80;cout<<"-",i2++);
for (int j=0;j<i1;j++){
int sw=0;
for (int k=0;k<i;k++)
if (t[k]!=b[j].salechap[k])
sw=1;
if (sw==0) {
cout<<b[j].name<<"\t\t";
cout<<b[j].writer<<"\t\t";
cout<<b[j].nasher<<"\t\t";
cout<<b[j].nasher<<"\t\t";
cout<<b[j].salechap<<"\n\n";
}
}
ch=getch();
}
}