Documentos de Académico
Documentos de Profesional
Documentos de Cultura
INTRODUCCIN A LA PROGRAMACIN
GRUPO 301304_47
INTRODUCCIN A LA PROGRAMACIN
FASE 3 DEPURAR PROGRAMA
PRCTICA 2 - EVALUACIN FINAL
PRESENTADO POR
TUTOR
En este trabajo se realizan las lecturas de los recursos tericos correspondientes a la Unidad 3,
con el fin de obtener conocimientos e implementarlos para disear y desarrollar programas
ESCUELA DE CIENCIAS BSICAS TECNOLOGAS E INGENIERA
INTRODUCCIN A LA PROGRAMACIN
GRUPO 301304_47
DESAROLLO DE LA ACTIVIDAD
PROBLEMA
1
ESCUELA DE CIENCIAS BSICAS TECNOLOGAS E INGENIERA
INTRODUCCIN A LA PROGRAMACIN
GRUPO 301304_47
DISEO DE LA SOLUCION
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#ifdef __linux__
#include <termios.h>
#include <unistd.h>
#define CLEAR_SCREEN "clear"
#define aacute "\xC3\xA1"
#define oacute "\xC3\xB3"
#define uacute "\xC3\xBA"
#define Uacute "\xC3\x9A"
int _getch ();
#else
#include <conio.h>
#define CLEAR_SCREEN "cls"
#define aacute "\240"
#define oacute "\242"
#define uacute "\243"
#define Uacute "\351"
#endif
using namespace std;
class Contacto {
public:
string telefono;
string nombre;
Contacto() {}
~Contacto() {}
2
ESCUELA DE CIENCIAS BSICAS TECNOLOGAS E INGENIERA
INTRODUCCIN A LA PROGRAMACIN
GRUPO 301304_47
{
return this!=&contacto && this->telefono!=contacto.telefono;
}
int main ()
{
vector<Contacto> contactos;
vector<Contacto>::iterator i;
Contacto *dato, contacto;
int contador=0, opcion;
char campo[255];
ifstream entrada (ruta);
if (entrada!=NULL)
{
while (leer_campo (entrada, campo, '\t'))
{
contacto.telefono = campo;
leer_campo (entrada, campo, '\n');
contacto.nombre = campo;
contactos.push_back (contacto);
}
entrada.close();
3
ESCUELA DE CIENCIAS BSICAS TECNOLOGAS E INGENIERA
INTRODUCCIN A LA PROGRAMACIN
GRUPO 301304_47
}
do {
system (CLEAR_SCREEN);
cout << "MEN" Uacute << endl;
cout << "1.- Altas" << endl;
cout << "2.- Consultas" << endl;
cout << "3.- Actualizaciones" << endl;
cout << "4.- Bajas" << endl;
cout << "5.- Ordenar registros" << endl;
cout << "6.- Listar registros" << endl;
cout << "7.- Salir" << endl;
cout << "Seleccione una opci" oacute "n:" << endl;
do
opcion = _getch ();
while (opcion<'1' || opcion>'7');
cout << (char)opcion << endl << endl;
if (contactos.empty() && opcion!='1' && opcion!='7')
{
pausar ("No hay registros.\n");
continue;
}
if (opcion<'5')
{
contacto.telefono = leer_cadena ("Ingrese el telefono del contacto");
i = find (contactos.begin(), contactos.end(), contacto);
dato = i != contactos.end() ? &contactos[i - contactos.begin()] : NULL;
if (dato!=NULL)
{
cout << endl;
Contacto::imprimir (*dato, &contador);
}
}
if (opcion=='1' && dato!=NULL)
cout << "El registro ya existe." << endl;
else if (opcion>='2' && opcion<='4' && dato==NULL)
cout << endl << "Registro no encontrado." << endl;
else switch (opcion)
{
case '1':
contacto.nombre = leer_cadena ("Ingrese el nombre");
contactos.push_back (contacto);
cout << endl << "Registro agregado correctamente." << endl;
break;
case '3':
dato->nombre = leer_cadena ("Ingrese el nuevo nombre");
cout << endl << "Registro actualizado correctamente." << endl;
break;
case '4':
4
ESCUELA DE CIENCIAS BSICAS TECNOLOGAS E INGENIERA
INTRODUCCIN A LA PROGRAMACIN
GRUPO 301304_47
return str;
}
#ifdef __linux__
int _getch ()
{
int ch;
struct termios oldt, newt;
tcgetattr (STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~(ICANON | ECHO);
tcsetattr (STDIN_FILENO, TCSANOW, &newt);
ch = getchar();
tcsetattr (STDIN_FILENO, TCSANOW, &oldt);
return ch;
}
#endif
CONCLUSIONES
6
ESCUELA DE CIENCIAS BSICAS TECNOLOGAS E INGENIERA
INTRODUCCIN A LA PROGRAMACIN
GRUPO 301304_47
Por medio del desarrollo de esta fase se promueve la investigacin en el estudiante porque
requiere de planeacin, implementacin y evaluacin de proyectos. Involucra al estudiante con
la investigacin para tomar decisiones. Favorece el aprendizaje autnomo.
REFERENCIAS
7
ESCUELA DE CIENCIAS BSICAS TECNOLOGAS E INGENIERA
INTRODUCCIN A LA PROGRAMACIN
GRUPO 301304_47
Joyanes Aguilar, Luis, and Snchez Garca, Lucas. Programacin en C++: un enfoque prctico :
un enfoque prctico. Madrid, ES: McGraw-Hill Espaa, 2009. ProQuest ebrary . Funciones y
mdulos. Disponible en http://datateca.unad.edu.co/contenidos/301304/2016-
2/U2/Funciones_y_modulos.pdf
Joyanes Aguilar, Luis, and Snchez Garca, Lucas. Programacin en C++: un enfoque prctico :
un enfoque prctico. Madrid, ES: McGraw-Hill Espaa, 2009. ProQuest ebrary . Estructuras de
control repetitivas. Disponible en
http://bibliotecavirtual.unad.edu.co:2077/lib/unadsp/reader.action?
ppg=1&docID=10491298&tm=1467436778252
Joyanes Aguilar, Luis, Castillo Sanz, Andrs, and Snchez Garca, Lucas. C algoritmos,
programacin y estructuras de datos. Madrid, ES: McGraw-Hill Espaa, 2009. ProQuest ebrary.
http://bibliotecavirtual.unad.edu.co:2077/lib/unadsp/reader.action?
ppg=1&docID=10491350&tm=1467436944090