necersito que me ayuden o me digan como incluir registros en un arreglo...
Publicado por Johannes (1 intervención) el 20/11/2014 14:05:02
Hola q tal, escribo para ver si me pueden ayudar ha incluir registron en un arreglo pero q el id de los registros no sean igual(osea q el proyecto no me deje incluir id iguales ), este es mi codigo se ven un error por fa decirme
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#include <iostream>
#include<conio.h>
using namespace std;
struct libros{
int Cota;
char Nombre[30];
char Descripcion_Del_Libro[100];
char Editorial[30];
int Anyo;
}var;
libros datosp[100];
//=========================================
void registro(){
int i=0;
for(i=0;i<5;i++){
datosp[i]=var;
cout<<"Introduzca El Cota Del Libro: ";
cin>>datosp[i].Cota;
cout<<"Introduzca El Nombre Del Libro: ";
cin>>datosp[i].Nombre;
cout<<"Introduzca La Descripcion Del Libro: ";
cin>>datosp[i].Descripcion_Del_Libro;
cout<<"Introduzca La Editorial Del Libro: ";
cin>>datosp[i].Editorial;
cout<<"Introduzca El Año: ";
cin>>datosp[i].Anyo;
cout<<"---------------------------------"<<endl;
}
}
//========================================
void mostrar(){
int i=0;
cout<<"------------------ RESULTADO ------------------------"<<endl;
for(i=0;i<5;i++){
var=datosp[i];
if(var.Cota!=0){
cout<<"Cota\n: "<<var.Cota<<endl;
cout<<"Nombre\n: "<<var.Nombre<<endl;
cout<<"Descrpcion\n: "<<var.Descripcion_Del_Libro<<endl;
cout<<"Editorial\n: "<<var.Editorial<<endl;
cout<<"Anyo\n: "<<var.Anyo<<endl;
cout<<"---------------------------------"<<endl;
}
}
}
//============================================================
void buscar(){
int i=0,existe=0;
int Cota=0;
cout<<" Buscar Libro"<<endl;
cout<<" ====================================================================="<<endl;
cout<<" Introduzca la Cota a buscar:";
cin>>Cota;
if(Cota==0){
cout<<"........................................"<<endl;
cout<<". Cota invalida, Vuelva A Intentar. ."<<endl;
cout<<"........................................"<<endl;
}else{
cout<<"== RESULTADO DE LA BUSQUEDA ========================================"<<endl;
for(i=0;i<5;i++){
var=datosp[i];
if(Cota==var.Cota){
cout<<"Cota\n: "<<var.Cota<<endl;
cout<<"Nombre\n: "<<var.Nombre <<endl;
cout<<"Descripcion\n: "<<var.Descripcion_Del_Libro<<endl;
cout<<"Editorial\n: "<<var.Editorial<<endl;
cout<<"Año\n: "<<var.Anyo<<endl;
cout<<"---------------------------------"<<endl;
existe=1;
}
}
if(existe==0){
cout<<"........................................."<<endl;
cout<<". Cota No Existe, Vuelva A Intentar. ."<<endl;
cout<<"........................................."<<endl;
}
}
}
//========================================================
void eliminar(){
int i=0,existe=0;
int Cota=0;
cout<<" Buscar Libro A Eliminar"<<endl;
cout<<" ====================================================================="<<endl;
cout<<" Introduzca La Cota A Eliminar:";
cin>>Cota;
if(Cota==0){
cout<<"........................................"<<endl;
cout<<". Cota Invalida, Vuelva A Intentar. ."<<endl;
cout<<"........................................"<<endl;
}else{
for(i=0;i<5;i++){
var=datosp[i];
datosp[i]=var;
if(Cota==var.Cota){
existe=1;
datosp[i].Cota=0;
// datosp[i].Nombre=0;
// datosp[i].Descripcion_Del_Libro=0;
// datosp[i].Editorial=0;
datosp[i].Anyo=0;
cout<<"*** Libro Eliminado Con Exito. ***"<<endl;
}
}
if(existe==0){
cout<<"........................................."<<endl;
cout<<". Cota No Existe, Vuelva A Intentar. ."<<endl;
cout<<"........................................."<<endl;
}
}
}
//========================================
void modificar(){
int i=0,existe=0;
int Cota=0;
cout<<" Buscar Libro A Modificar"<<endl;
cout<<" ====================================================================="<<endl;
cout<<" Introduzca La Cota A Modificar:";
cin>>Cota;
if(Cota==0){
cout<<"........................................"<<endl;
cout<<". Cota Invalida, Vuelva A Intentar. ."<<endl;
cout<<"........................................"<<endl;
}else{
for(i=0;i<5;i++){
var=datosp[i];
if(Cota==var.Cota){
existe=1;
datosp[i]=var;
cout<<"Introduzca La Cota: ";
cin>>datosp[i].Cota;
cout<<"Introduzca El Nombre: ";
cin>>datosp[i].Nombre;
cout<<"Introduzca La Descripcion: ";
cin>>datosp[i].Descripcion_Del_Libro;
cout<<"Introduzca La Editorial : ";
cin>>datosp[i].Editorial;
cout<<"Introduzca El Año: ";
cin>>datosp[i].Anyo;
cout<<"---------------------------------"<<endl;
cout<<"*** Libro Modificado Con Exito. ***"<<endl;
}
}
if(existe==0){
cout<<"........................................."<<endl;
cout<<". Cota No Existe, Vuelva A Intentar. ."<<endl;
cout<<"........................................."<<endl;
}
}
}
//============================================================
void salir(){
cout<<"........................................."<<endl;
cout<<". S A Y O N A R A ."<<endl;
cout<<"........................................."<<endl;
}
// MENU PRINCIPAL
void menu_principal(){
system ("color 0A");
cout<<"\t\t########################################################"<<endl;
cout<<"\t\t# #"<<endl;
cout<<"\t\t# B I B L I O T E C A #"<<endl;
cout<<"\t\t# #"<<endl;
cout<<"\t\t########################################################\n"<<endl;
cout<<"\t\t-----------------------------------------"<<endl;
cout<<"\t\t-- M E N U P R I N C I P A L --"<<endl;
cout<<"\t\t-----------------------------------------\n\n"<<endl;
cout<<"\t 1. Ingresar Libro.\n"<<endl;
cout<<"\t 2. Modificar Libro.\n"<<endl;
cout<<"\t 3. Eliminar Libro.\n"<<endl;
cout<<"\t 4. Buscar Libro.\n"<<endl;
cout<<"\t 5. Mostrar Todos Los Libros.\n"<<endl;
cout<<"\t 0. Salir.\n"<<endl;
cout<<""<<endl;
cout<<"\t\t Seleccione una opcion:";
}
// =======================================
main(){
int opcion;
do{
menu_principal();
cin>>opcion;
if(opcion==1){
registro();
}
if(opcion==2){
modificar();
}
if(opcion==3){
eliminar();
}
if(opcion==4){
buscar();
}
if(opcion==5){
mostrar();
}
}while(opcion!=0);
}
Valora esta pregunta
0