-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathejemplostructarray
More file actions
166 lines (154 loc) · 3.15 KB
/
ejemplostructarray
File metadata and controls
166 lines (154 loc) · 3.15 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
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
#include "stdafx.h"
#include <iostream>
#include "conio.h"
#include <string>
#include "stdlib.h"
#define MAX 6
using namespace std;
struct tintereses
{int numero;
string interes;
string descripcion;
int estado;
};
tintereses V[MAX];
int insertar();
void listar(int N);
void consultar(int N);
void modificar(int N);
void borrar();
void clasificar();
void main()
{int N, opc;
do{
cout<<"\n MENU ";
cout<<"\n [1]---> Insertar";
cout<<"\n [2]---> Listar";
cout<<"\n [3]---> Consultar";
cout<<"\n [4]---> Modificar";
cout<<"\n [5]---> Borrar";
cout<<"\n [6]---> Clasificar los datos";
cout<<"\n [0]---> Salir";
cout<<"\n Ingrese la opcion: ";
cin>>opc;
switch(opc)
{ case 1:N=insertar();
break;
case 2:listar(N);
break;
case 3:consultar(N);
break;
case 4:modificar(N);
break;
case 5:borrar();
break;
case 6:clasificar();
break;
case 0:cout<<"salir";
break;
default:cout<<"error";
break;
}
getch();
system("cls");
}while(opc!=0);
getch();
}
int insertar()
{ int N;
cout<<" Ingrese el numero de datos que desee insertar: ";
cin>>N;
for(int i=0;i<N;i++)
{ cout<<"Ingrese el ID: "<<endl;
cin>>V[i].numero;
cout<<"Ingrese el interes: "<<endl;
cin.ignore();
getline(cin,V[i].interes);
cout<<"Ingrese la descripcion: "<<endl;
getline(cin,V[i].descripcion);
V[i].estado=0;
getch();
}
return N;
}
void listar(int N)
{
cout<<" Listado"<<endl;
cout<<"ID"<<"\t ";
cout<<"Interes"<<"\t";
cout<<"Descripcion"<<"\t"<<endl;
for(int i=0;i<N;i++)
{ if (V[i].estado !=9)
{ cout<<V[i].numero<<"\t";
cout<<V[i].interes<<"\t";
cout<<V[i].descripcion<<endl;
}
}
}
void consultar(int N)
{
int idElemento;
bool band = true;
cout << "Ingrese el elemento a consultar: ";
cin >> idElemento;
for(int i=0;i<N;i++){
if(V[i].numero == idElemento){
cout << "Interes: " << V[i].interes;
cout << "\tDescripcion: " << V[i].descripcion;
band = false;
}
}
if (band != false)
cout << "Elemento Ingresado No Encontrado en la base de Datos. " << endl;
}
void modificar(int N)
{int idElemento;
bool band = true;
char resp;
cout << "Ingrese el elemento a modificar: ";
cin >> idElemento;
for(int i=0;i<N;i++){
if(V[i].numero == idElemento){
band = false;
cout << "Interes: " << V[i].interes<<endl;
cout << "Desea modificar el dato: (coloque s): ";
cin>>resp;
cin.ignore();
if (resp=='s')
{
cout << "Ingrese el nuevo dato:";
getline(cin,V[i].interes);
}
cout << "Descripcion: " << V[i].descripcion<<endl;
cout << "Desea modificar el dato: (coloque s): ";
cin>>resp;
cin.ignore();
if (resp=='s')
{
cout << "Ingrese el nuevo dato: ";
getline(cin,V[i].descripcion);
}
}
}
if (band != false)
cout << "Elemento Ingresado No Encontrado en la base de Datos. " << endl;
}
void borrar()
{
// Borrar logico
int idElemento;
bool band = true;
cout << "Ingrese el elemento a borrar: ";
cin >> idElemento;
for(int i=0;i<N;i++){
if(V[i].numero == idElemento){
V[i].estado=9;
band = false;
}
}
if (band != false)
cout << "Elemento Ingresado No Encontrado en la base de Datos. " << endl;
}
void clasificar()
{
}