Nombres en una lista con c++

Programa que agrega nombres, cursos en una lista ligada y posteriormente se puede recorrer la lista ligada e elimina elementos de la lista

lista

#include "iostream.h"
#include "conio.h"
#include "stdio.h"
#include "ctype.h"
#include "string.h"
#include "dos.h"
#include "stdlib.h"
#include "alloc.h"

struct datos{ //Esta es laestructura de los datos que  contendr  la lista
      char nombres[25];
      char apellidos[25];
      int codigo;
      char curso;
      long cedula;
      datos *sig;/*Declaramos datos para que apunte a siguiente*/};

class nombres{ //Contruimos un constructor en donde declaramos los apuntador
    struct datos  *cab,*p,*q;
public: // Creacion de las funciones miembros
    nombres(){cab=NULL;}
    void crear(int co);   //Procedimiento que crea una lista y permite adiocionar datos
    void recorrer(int co);//
    void eliminar(int co);

};
void nombres::eliminar(int co){
clrscr();char R;
gotoxy(29,5);cout << "PROCEDIMIENTO ELIMINAR";
gotoxy(29,7);cout << "Esta seguro de querer liberalo S/N .. ";
cin >> R;
if (toupper(R)=='S')
{if (co==cab->codigo)
   {p=cab;
    cab=p->sig;
    free(p);
    gotoxy(29,10);cout << "Codigo Eliminado";
   }
 else
  {q=cab;p=q->sig;
   while (p->sig!=NULL){q=p;p=p->sig;}
   if (co==p->codigo)
     {q->sig=NULL;
      free(p);
      gotoxy(29,10);cout << "Codigo Eliminado";
     }
   else
   {q=cab;p=q->sig;
    while (co!=p->codigo || p==NULL){q=p;p=p->sig;}
    if (co==p->codigo)
      {q->sig=p->sig;
       free(p);
       gotoxy(29,10);cout << "Codigo Eliminado";
      }
    else
    {gotoxy(29,10);cout << "Codigo Inexistente";getch();}
   }
  }
}
getch();
}

void nombres::recorrer(int co){
clrscr();p=cab;
gotoxy(29,5);cout << "PROCEDIMIENTO RECORRER";
for (int i=1;i<=co;i++){
  gotoxy(6,i+6);
  cout <<i<<" Nombres "<<p->nombres<<", Apellidos "<<p->apellidos<<", Codigo "<<p->codigo<<", Curso "<<p->curso<<", Cedula "<<p->cedula<<"\n";
  p=p->sig;
  }
getch();

}

void nombres::crear(int co){
   clrscr();int i;
/*   gotoxy(24,2);cout << "Digite cuantos va a ingresar...";
   cin >> co;*/
for (i=1;i<=co;i++)
  {p = new /*struct*/ datos;
//   char nombres[20]; char apellidos[20];
//   int codigo; char curso; float cedula;
   clrscr();
   gotoxy(23,5);cout << "PROCEDIMIENTO DE CREAR Y ADICIONAR";
   gotoxy(28,7);cout << "Digite los Nombres...";
   cin >> p->nombres;
   gotoxy(28,8);cout << "Digite Apellidos...";
   cin >> p->apellidos;
   gotoxy(28,9);cout << "Digite un Codigo...";
   cin >> p->codigo;
   gotoxy(28,10);cout << "Digite Curso...";
   cin >> p->curso;
   gotoxy(28,11);cout << "Digite Cedula...";
   cin >> p->cedula;
   if (cab==NULL){cab=p; q=p;} else {q->sig=p; q=p;}
   clrscr();
   }

}

main (){int res;nombres X;
do{  clrscr();
     gotoxy(5,2);cout << "1. Crear y adicionar";
     gotoxy(32,2);cout << "2. Recorrer";
     gotoxy(47,2);cout << "3. Eliminar";
     gotoxy(65,2);cout << "4. Salir";

     gotoxy(23,4);cout << "Digite su opci¢n ...\n";
     gotoxy(48,4);cin >> res;
     int n;

     switch(res)
     {case 1:clrscr();
	     gotoxy(24,2);cout << "Digite cuantos va a ingresar...";
	     cin >> n;
	     X.crear(n);break;
      case 2:X.recorrer(n);break;
      case 3:clrscr();long eli;
	     gotoxy(29,7);cout << "Digite codigo a eliminar ...";
	     cin >> eli;
	     X.eliminar(eli);



     }

}while(res!=4);
}







para descargar el código .cpp hacerlo

si te parecio de utilidad  dar “me gusta” o dale tweet en la parte de abajo

Familia con poo en c++

Programa que modela la estructura de una familia con programación orientada a objetos. modela desde el padre,madre, hijo,hija.

modelado con poo

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>

class familia{
	       char padre[30];
	       char madre[30];
	       char hijo[30];
	       char hija[30];

            public:
	       void captura ();
	       };

	       void familia::captura()
	       {
               gotoxy(20,7);cout<<"ESTE PROGRAMA CAPTURA LA FAMILIA MOSQUITO";

	       gotoxy(25,10);cout<<"Nombre del padre  :";
	       gotoxy(25,11);cout<<"Nombre de la Madre:";
	       gotoxy(25,12);cout<<"Nombre del Hijo   :";
	       gotoxy(25,13);cout<<"Nombre de la Hija :";
               gotoxy(45,10);cin>>padre;
	       gotoxy(45,11);cin>>madre;
               gotoxy(45,12);cin>>hijo;
	       gotoxy(45,13);cin>>hija;

               gotoxy(45,16);cout<<"pulse Alt f4 para terminar";
               getch();
	       }

main()
{
  familia adalgiza;
  adalgiza.captura();
  return(0);
}                	       

para descargar el código .cpp hacerlo

si te parecio de utilidad  dar “me gusta” o dale tweet en la parte de abajo

Interrupciones de cpu en c++

Programa que hace uso de las interrupciones del sistema para dar información del cpu, verifica unidades de disco y checa

cpu

 

/* ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ
 Þ biosequip and _bios_equiplist Ý   <BIOS.H>
 ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ

 Checks equipment

 Declaration:
  þ int biosequip(void);
  þ unsigned _bios_equiplist(void);

 Remarks:
biosequip and _bios_equiplist use BIOS
interrupt 0x11 to return an integer describing
the equipment connected to the system.

 Return Value:
The return value is interpreted as a
collection of bit-sized fields.

    ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Number of parallel printers installed:
    ³                      00 = 0; 01 = 1; 10 = 2; 11 = 3
    ³   ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Serial printer attached
    ³   ³  ÚÄÄÄÄÄÄÄÄÄÄÄÄ Game I/O attached
    ³   ³  ³     ÚÄÄÄÄÄÄ Number of COM ports: 000 = 0, 001 = 1,..., 111 = 7
    ³   ³  ³     ³     Ú Direct memory access (DMA)
    ³   ³  ³     ³     ³   0 = Machine has DMA; 1 = Machine doesn't have DMA
 ÉÍÍÑÍÍÎÍÍÎÍÍÎÍÍÑÍÍÑÍÍÎÍÍÎÍÍÑÍÍËÍÍÑÍÍËÍÍÑÍÍËÍÍËÍÍ»
 º15³14º13º12º11³10³ 9º 8º 7³ 6º 5³ 4º 3³ 2º 1º 0º
 ÈÍÍÏÍÍÊÍÍÊÍÍÊÍÍÏÍÍÏÍÍÊÍÍÎÍÍÏÍÍÎÍÍÏÍÍÎÍÍÏÍÍÎÍÍÎÍͼ
 Number of disk drives:  ÄÄÄÙ     ³     ³    ³  ³
   00 = 0; 01 = 1; 10 = 2; 11 = 3 ³     ³    ³  ³
 Initial video mode  ÄÄÄÄÄÄÄÄÄÄÄÄÄÙ     ³    ³  ³
   00 = Unused                          ³    ³  ³
   01 = 40x25 BW with color card        ³    ³  ³
   10 = 80x25 BW with color card        ³    ³  ³
   11 = 80x25 BW with mono card         ³    ³  ³
 Motherboard RAM size  ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ    ³  ³
   00 = 16K; 01 = 32K; 10 = 48K; 11 = 64K    ³  ³
 Floating-point coprocessor  ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ  ³
 Boot from disk  ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

 þ NOTE: DOS only sees two ports but can be
pushed to see four; the IBM PS/2 can see up to
eight.

 Portability:
 É DOS Ñ UNIX Ñ ANSI C Ñ C++ Only »
 º Yes ³      ³        ³          º
 ÈÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍͼ

 Examples:
  biosequip example
  _bios_equiplist example*/

/* biosequip example
ßßßßßßßßß
ßßßßßßßßßß*/

#include <bios.h>
#include <stdio.h>
#include <conio.h>

#define CO_PROCESSOR_MASK 0x0003
#define Disk_driver 0x0005

int main(void)
{  clrscr();
   int equip_check;
   int Disk_check;

   equip_check = biosequip();

   if (equip_check & CO_PROCESSOR_MASK)
      printf("There is a math coprocessor installed.\n");
   else
      printf("No math coprocessor installed.\n");

     Disk_check = biosequip();
     if ((Disk_check & Disk_driver) == 00)
	printf("No tiene unidad de disco.\n");
     else
	{if ((Disk_check & Disk_driver) == 01)
	  printf("Tiene una (1) unidad de disco.\n");
	 else
	   {if ((Disk_check & Disk_driver) == 02)
	      printf("Tiene una (2) unidad de disco.\n");
	    else
	       {if ((Disk_check & Disk_driver) == 03)
		printf("Tiene una (3) unidad de disco.\n");
		else
		     printf("Error en lectura");
		}
	     }
	 }







   getch();
   return 0;
}



para descargar el código .cpp hacerlo

si te parecio de utilidad  dar “me gusta” o dale tweet en la parte de abajo

Compara vectores en c++

Programa que compara dos vectores introducidos por el usuario y dice si son iguales. el programa tiene una clase compara que es donde están los métodos

compara

#include "iostream.h"
#include "conio.h"
#include "stdlib.h"
#include "string.h"

class comparar{
       private:
       char cad1[10];
       char cad2[10];

       public:
         void vector();
       };

       void comparar::vector()
       {

	clrscr();

	gotoxy(25,10);cout <<"DIGITE CADENA1.....[                      ]";
	gotoxy(45,10);cin >>cad1;

	gotoxy(25,12);cout <<"DIGITE CADENA2..... [                     ]";
	gotoxy(47,12);cin >>cad2;

 	 if (strcmp(cad1,cad2)==0)
 	 {

	   gotoxy(35,15);cout<<"LOS VECTORES SON IGUALES";
   	   }
	else
        {
	  gotoxy(35,15);cout<<"LOS VECTORES NO SON IGUALES";
 	  }

     }

        main()
       {
       comparar compara;
       compara.vector();
       }

para descargar el código .cpp hacerlo

si te parecio de utilidad  dar “me gusta” o dale tweet en la parte de abajo

Datos empelado con class en c++

Programa que muestra los datos de un empelado. la información del empleado esta modelada en una clase de programación orientada a objetos

class

//#include<stdio.h"
#include<ctype.h>
#include<conio.h>
#include<string.h>
#include<iostream.h>
# include"stdio.h"
#include<dos.h>

class empleado
{
public:
char nombre[40];
long tel_emp;
float salario;
//void marco();
void sal_emp(void);//funcion definida de la clase
};

void empleado::sal_emp(void){
cout<<"NOMBRE:"<<nombre<<endl;
cout<<"TELEFONO:"<<tel_emp<<endl;
cout<<"SALARIO:"<<salario<<endl;
};

void main(void)
{
//clrscr();
textcolor(0);
textbackground(3);
clrscr();
//marco(2,79,2,24);
empleado operario,jefe,admo;//nombre de la clase//variable de la clase objecto
strcpy(operario.nombre,"pedro perez");
operario.tel_emp=703040;
operario.salario=45703040;
strcpy(operario.nombre,"jose perez");
jefe.tel_emp=709876;
jefe.salario=455676;
strcpy(admo.nombre,"jose pullon");
admo.tel_emp=3709876;
admo.salario=3455676;
operario.sal_emp();//llamada de la funcion
jefe.sal_emp();
admo.sal_emp();
getch();
}




para descargar el código .cpp hacerlo

si te parecio de utilidad  dar “me gusta” o dale tweet en la parte de abajo

Consulta de clientes en c++

Programa que realiza consultas de clientes en un sistema. el sistema esta segmentado por módulos estructurados en struct. tiene funciones. se pueden costurar nombre, dirección y teléfono de los clientes

consulta

#include "stdio.h"
#include "conio.h"
#include "string.h"
#include "ctype.h"
#define go {gotoxy(1,24);}
#define enter 13
struct cliente
{int codigo;
 char nombre[20];
 char apellido[20];
 char direccion[20];
 char telefono[10];
 };
struct  cliente agenda[50];
void boli (int f1,int f2, int col1,int col2);
void crear();
salir();
void consultar();
void modificar();
void individual();
void general();
void borrar();
void cuad(int ci,int fi,int cf,int ff);
void cuadro3(int x1,int y1,int x2,int y2,char a1[],char a2[],char a3[],char a4[],char a5[], char a6[],char a7[],char a8[],char a9[],char a10[]);
buscar(int codi);
void validar(int fil,int col);
menu();
void pantalla(int fila, int columna);
char vec[5][13],cad[30];
char nombre,apellido,direccion,telefono,tel[10],dir[20],nom[30],ape[30];
int d,res,e,max=0,q,op,n,sto,r,x;
int i=0,j=0,g,codigo,cod,opcion,s,k=0;
char tecla;
static char MODIFICAR[5][12]={"Nombre    ","Apellido  ","Direcci¢n ","Tel‚fono  ","Salir     "};
static char CONSULTAR[3][12]={"GENERAL   ","INDIVIDUAL","SALIR     "};
int menuVertical(int col,int fi ,char v[][12], int t);

/*------------------------------------------*/
int h,h2;
int menuVertical(int col,int fi ,char v[][12], int t)
{
 int i,j=0;
  char tecla;
  do
  {
   textbackground(7);
   for(i=0;i<t;i++)
     { if (i==j)
      { textcolor(0);
	textbackground(10);
	gotoxy(col,fi+i);cprintf("%s",v[i]);
	}
      else
	{ textcolor(0);textbackground(11);
	  gotoxy(col,fi+i);cprintf("%s",v[i]);}
	  }

	 tecla=getch();
	if (tecla==80)
	{  if (j<t-1)
	    j++;
	   else
	    j=0;
	}
	 if (tecla==72)
	   { if (j!=0)
	      j--;
	     else
	      j=t-1;
	   }

  }while (tecla!=13);
  textbackground(7);return(j);
}

void main()
{ clrscr();
do{
clrscr();
cuad(1,3,80,22);
textbackground(7);
strcpy(vec[0],"   ADICION  ");
strcpy(vec[1],"MODIFICACION");
strcpy(vec[2],"  CONSULTA  ");
strcpy(vec[3],"  BORRAR    ");
strcpy(vec[4],"   SALIR    ");
opcion=menu();
    if (opcion==0)
    { crear();}
      if (opcion==1)
      {modificar();}
	if (opcion==2)
	{ do{
		 boli(4,18,20,76);
		 boli(4,10,35,47);
		 cuad(37,4,48,8);h2=menuVertical(38,5,CONSULTAR,3);//cuad(2,5,80,22);
		  if (h2== 0)
		 {boli(4,8,37,49); general();
		 }
		 if (h2==1)
		 {boli(4,8,37,49); individual();
		 }
	      }while(h2!=2);

	   }
	if(opcion==3)
	{borrar();}
}while (opcion!=4);
normvideo();
}
/*---------------------------------------------*/
void cuadro3(int x1,int y1,int x2,int y2,char a1[],char a2[],char a3[],char a4[],char a5[], char a6[],char a7[],char a8[],char a9[], char a10[])
{
  int p;
  for(p=x1;p<=x2;p++)
  {
    gotoxy(y1,p);cprintf(a1);
    gotoxy(y2,p);cprintf(a1);
    gotoxy(9,p);cprintf(a1);
  }
  for(p=y1;p<=y2;p++)
  {
      gotoxy(p,x1);cprintf(a2);
      gotoxy(p,x2);cprintf(a2);
      gotoxy(p,21);cprintf(a2);
      gotoxy(p,3);cprintf(a2);
  }
      gotoxy(y1,x1);cprintf(a3);
      gotoxy(y2,x2);cprintf(a4);
      gotoxy(y2,x1);cprintf(a5);
      gotoxy(y1,x2);cprintf(a6);
      gotoxy(1,21);cprintf(a7);
      gotoxy(80,21);cprintf(a8);
      gotoxy(1,3);cprintf(a7);
      gotoxy(80,3);cprintf(a7);
      gotoxy(9,3);cprintf(a9);
      gotoxy(9,1);cprintf(a10);
}

/*---------------------------------------------*/
void cuad(int ci,int fi,int cf,int ff)
 {  int i;
   i=ci;
   textcolor(0);
   for (i=ci;i<=cf;i++)
   {
    gotoxy(i,fi);cprintf("Í");
    gotoxy(i,ff);cprintf("Í");
   }
   i=fi;
   for (fi=i;i<=ff;i++)
   {
     gotoxy(ci,i);cprintf("º");
     gotoxy(cf,i);cprintf("º");
   }
    gotoxy(ci,fi);cprintf("É");
    gotoxy(cf,fi);cprintf("»");
    gotoxy(ci,ff);cprintf("È");
    gotoxy(cf,ff);cprintf("¼");
 }

void pantalla (int fila, int columna)
{boli(49,5,75,9);
  textcolor(0);
 gotoxy(columna,fila);cprintf  ("C¢digo   :");
 gotoxy(columna,fila+1);cprintf("Nombre   :");
 gotoxy(columna,fila+2);cprintf("Apellido :");
 gotoxy(columna,fila+3);cprintf("Direcci¢n:");
 gotoxy(columna,fila+4);cprintf("Tel‚fono :");
}
/*---------------------------------------------*/

void crear()
{do
 { cuad(3,4,35,10);
  pantalla(5,4);
  boli(5,9,16,34);
  textcolor(15);
  gotoxy(16,5);scanf("%d",&cod);
  if (buscar(cod)==0)
  {
   validar(16,6);
   strcpy(nom,cad);
   fflush(stdin);
   validar(16,7);
   strcpy(ape,cad);
   gotoxy(16,8);gets(dir);
   gotoxy(16,9);gets(tel);
   agenda[j].codigo=cod;
   strcpy(agenda[j].nombre,nom);
   strcpy(agenda[j].apellido,ape);
   strcpy(agenda[j].direccion,dir);
   strcpy(agenda[j].telefono,tel);
  }
  else
 { boli(5,5,16,34);
   gotoxy(16,5);printf("%d",agenda[max].codigo);
   gotoxy(16,6);printf("%s",agenda[max].nombre);
   gotoxy(16,7);printf("%s",agenda[max].apellido);
   gotoxy(16,8);printf("%s",agenda[max].direccion);
   gotoxy(16,9);printf("%s",agenda[max].telefono);
   gotoxy(14,20);textcolor(0);cprintf("ESTE CODIGO YA SE ENCUENTRA << ENTER PARA CONTINUAR >>");
   getch();
   boli(20,20,14,70);
 }
  j++;
  max=0;
   gotoxy(28,20);textcolor(0);cprintf("DESEA CONTINUAR S/N [ ]");
   gotoxy(49,20);res=getch();

  res=toupper(res);

  }while (res!='N');
}

/*---------------------------------------------------*/

 menu()
{
do
 {r=2;
  textcolor(0);
  textbackground(4);
  for (i=0;i<5;i++)
   {if (i==k)
    {textcolor(0);
     textbackground(5);
     gotoxy(2+r,2);cprintf("%s",vec[i]);
     }
     else
      {textcolor(15);textbackground(3);
       gotoxy(2+r,2);cprintf("%s",vec[i]);}
       r+=15;
       textcolor(0);
       textbackground(7);
       switch(k)
       {case 0:go;gotoxy(1,24);cprintf("                      Modulo para la adici•n de clientes                      ");
	textbackground(7);	break;
	case 1:go;cprintf("                                                                   ");
	gotoxy(20,24);cprintf("Modulo para la modificaci•n de clientes");
	       break;
	case 2:go; gotoxy(20,24);cprintf("Modulo para la consulta de clientes    ");
	       break;
	case 3:go; gotoxy(20,24);cprintf("Modulo para el borrado de clientes    ");
	       break;
	case 4:go; gotoxy(20,24);cprintf("Moduo para salir de la aplicai•n       ");
	       break;
       }
      }
      tecla=getch();
       if(tecla==77)
       {if (k<4)
	 k++;
	 else
	 k=0;
       }
       if (tecla==75)
	{if (k!=0)
	 k--;
	 else
	  k=4;
	}
 }
 while (tecla!=13);
 return(k);
 }


/*---------------------------------------------*/

buscar(int codi)
{int sw=0;
  while (sw==0 && max<j)
   {if (codi==agenda[max].codigo)
     sw=1;
     else
       max++;
    }

    return(sw);

}

/*----------------------------------------------*/


void boli (int f1, int f2, int col1, int col2)
{int i, j;
 {for (i=f1;i<=f2;i++)
   for (j=col1;j<col2;j++)
    {gotoxy(j,i);cprintf(" ");
    }
  }
}

/*------------------------------------------------*/

void validar(int fil,int col)
{ int i=0;
 cad[0]=' ';
  do
 {
   do
     {

      gotoxy(fil+i,col);res=getch();
      if ((res>='a' && res<='z')||(res>='A' && res<='Z')||(res==' '))
	{
	    cad[i++]=res;
	    gotoxy(fil-1+i,col);printf("%c",res);
	}
      }
  while (res!=13);
 }
 while (cad[0] == ' ');
 cad[i]='\0';
 }

/*----------------------------------------------*/

void consultar()
{
 }
 void general()
 { char tecla;
 do {
   boli(23,23,5,78);
   boli(4,10,39,59);
   boli(23,23,4,78);
   boli(4,11,9,24);
   gotoxy(21,5);cprintf("codigo");
   gotoxy(35,5);cprintf("nombre");
   cuad(20,4,75,18);


   for (n=0;n<=j;n++)
  { if (x<=3)
    {gotoxy(21,x+7);printf("%d",agenda[n].codigo);
      gotoxy(37,x+7);printf("%s",agenda[n].nombre);
      x++;

     }
     else
     {gotoxy(20,22);printf("DESEA CONTINUAR S/N");
      gotoxy(40,22);sto=getch();
      if (sto=='n')
       {n=j;
       }
       else
       {getch();
	x=0;
       }
      }
      }
      gotoxy(45,20);printf("DESEA CONTINUAR S/N  ");
   gotoxy(66,20);res=getch();
  res=toupper(res);
  }while (res!='N');
  }

void individual(){
do {
   boli(4,6,35,46);
   cuad(35,4,66,10);
   pantalla(5,36);
   gotoxy(49,5);scanf("%d",&cod);

  if (buscar(cod)!=0)
  {boli(5,5,49,65);
   gotoxy(49,5);printf("%d",agenda[max].codigo);
   gotoxy(49,6);printf("%s",agenda[max].nombre);
   gotoxy(49,7);printf("%s",agenda[max].apellido);
   gotoxy(49,8);printf("%s",agenda[max].direccion);
   gotoxy(49,9);printf("%s",agenda[max].telefono);
   gotoxy(13,20);printf("ESTOS SON SUS DATOS << ENTER PARA CONTINUAR >>");
   getch();boli(20,20,10,70);
 }
   else
  {gotoxy(11,20);printf("ESTE CODIGO NO EXISTE << ENTER PARA CONTINUAR >>");
    getch();boli(20,20,7,70);
  }
  +
    max=0;

   gotoxy(30,20);printf("DESEA CONTINUAR S/N [ ]    ");
   gotoxy(66,20);res=getch();
  res=toupper(res);
  }while (res!='N');
 }
/*----------------------------------------------------*/


void borrar()
{do
 {
   boli(23,23,4,79);
   cuad(48,4,75,10);
   pantalla(5,49);
   boli(5,9,60,74);
   gotoxy(60,5);scanf("%d",&cod);
   if (buscar(cod)!=0)
    {
     boli(5,5,60,75);
     gotoxy(60,5);printf("%d",agenda[max].codigo);
     gotoxy(60,6);printf("%s",agenda[max].nombre);
     gotoxy(60,7);printf("%s",agenda[max].apellido);
     gotoxy(60,8);printf("%s",agenda[max].direccion);
     gotoxy(60,9);printf("%s",agenda[max].telefono);
     gotoxy(22,20);textcolor(0);cprintf("SON DATOS QUE DESEA BORRAR S/N [ ]");
     gotoxy(54,20);e=getch();boli(20,20,22,65);
     e=toupper(e);
     if (e=='S')
     { if (max==j-1)
       {j--;
       }
       else
       {
	  for (s=max;s<j-1;s++)
	   agenda[s]=agenda[s+1];
	   j--;
	}
	  boli(23,23,4,79);
	  gotoxy(16,20);textcolor(0);cprintf("DATOS ELIMINANDO << ENTER PARA CONTINUAR >>");
	  getch(); boli(20,20,24,79);
     }
      else
     {
       boli(23,23,4,79);
       gotoxy(10,20);textcolor(0);cprintf("ESTOS DATOS NO HAN SIDO BORRADO << ENTER PARA CONTINUAR >>");
       getch();boli(20,20,14,70);
     }
   }
  else
   {
     boli(23,23,4,79);
     gotoxy(16,20);textcolor(0);cprintf("ESTE CODIGO NO EXISTE << ENTER PARA CONTINUAR >>");
     getch();  boli(20,20,30,70);
  }
    boli(20,20,4,79);
    max=0;
    gotoxy(24,20);textcolor(0);cprintf("DESEA CONTINUAR BORRANDO S/N [ ]");
    gotoxy(54,20);res=getch(); boli(20,20,24,70);

   res=toupper(res);

  }
   while (res!='N');
}


/*------------------------------------------------------*/
void modificar()
{int cod;
 do
{boli(5,9,32,49);
 boli(4,9,52,69);
 cuad(19,11,50,17);
 pantalla(12,20);
 gotoxy(32,12);scanf("%d",&cod);
 if (buscar(cod)!=0)
 {fflush(stdin);
 do
 {gotoxy(32,13);puts (agenda[max].nombre);
  gotoxy(32,14);puts(agenda[max].apellido);
  gotoxy(32,15);puts(agenda[max].direccion);
  gotoxy(32,16);puts(agenda[max].telefono);
  cuad(19,3,30,9);
  h=menuVertical(20,4,MODIFICAR,5);
     switch(h)
     {
   {case 0:{boli(13,13,32,45);validar(32,13); strcpy(nom,cad);
   strcpy(agenda[max].nombre,nom);}break;}
   {case 1:{boli(14,14,32,49);validar(32,14); strcpy(ape,cad);
    strcpy(agenda[max].apellido,ape);}break;}
   {case 2:{boli(15,15,32,49);gotoxy(32,15);gets(dir); strcpy(agenda[max].direccion,dir);
    }break;}
   {case 3:{boli(16,16,32,49);gotoxy(32,16);gets(tel);strcpy(agenda[max].telefono,tel);
    }break;}
   }

    gotoxy(19,20);textcolor(0);printf("DESEA CONTINUAR EN EL MISMO REGISTRO  S/N");
    gotoxy(61,20);g=getch();
    g=toupper(g);
    boli(20,20,19,62);
   }while (g!='N');
  }
 else
 {
  gotoxy(13,20);printf("CODIGO NO EXISTE << Enter para continuar >>");
   getch();
   gotoxy(13,20);printf("                                           ");
  }
 gotoxy(14,20);printf("DESEA CONTINUAR EN  OTRO REGISTRO S/N [ ]");
 gotoxy(53,20);sto=getch();
  sto=toupper(sto); boli(20,20,14,54);
} while (sto!='N');
}





para descargar el código .cpp hacerlo

si te parecio de utilidad  dar “me gusta” o dale tweet en la parte de abajo

Reportes en c++

Programa que captura datos y genera reportes. utiliza la programación orientada a objetos, tiene métodos públicos y privados lo que hace un programa bien estructurado

public

#include "iostream.h"
#include "conio.h"
#include "string.h"
#include "stdlib.h"

#define limpiar clrscr();
#define pos gotoxy


class factura
{
  private:
  	 char empresa[20];
	 char nfact[5];
	 char fecha[8];
	 char concepto[30];
	 float cant;
	 float  vunit;
	 float vtotal;
	 float iva;
	 char clave[5];
	 int op,c,f,i;
	 char tecla;
	 int nreg;
	 int reg;

  public:
        void acceso();
        void menu();
        void captura();
        void reporte();
        void finalizar();
 };








void factura::acceso()
{

  do
  {
   limpiar
   pos(20,9);cout <<  " ";
   pos(20,10);cout << " WELCOME TO MANANGER PROGRAM         ";
   pos(20,12);cout << " PLEASE ENTER YOU PASSWORD [     ]   ";
   pos(20,13);cout << " ";
   for (i=0; i<=4; i++)
   {
    pos(49+i,12);tecla=getch();cout << '*';
    clave[i]=tecla;
    }clave[i]='\0';

    strcpy(clave,strupr(clave));

    if (strcmp(clave,"RACSO")==0)
    {
     menu();
    }
    else
    {
     c++;
     limpiar
     pos(33,12);cout << "E R R O R..";
     pos(30,14);cout << "A C C E S    D E N I E D ";
     pos(30,20);cout << "Pulse  Enter ==> ACCESO ";
     getch();
     }

   }while(c<3);



 }



void factura::menu()
{

  while (1)
  {
   limpiar
    pos(32,12);cout <<"MENU PRINCIPAL";
    pos(29,14);cout <<" 1. CAPTURAR        ";
    pos(29,15);cout <<" 2. REPORTE GENERAL ";
    pos(29,16);cout <<" 3. FINALIZAR ";

    pos(29,18);cout <<"DIGITE OPCION [   ]";
    pos(45,18);cin >>op;



   if (op>3)
   {
     limpiar
     pos(29,14);cout << "Opcion Fuera de Rango";
     getch();
    }

    switch(op)
    {
	      case 1:captura();break;

	      case 2:reporte();break;

	      case 3:finalizar();break;

     }
  }


}




void factura::captura()
{

    nreg=1;
    while(1)
    {

     limpiar
      pos(25,10);cout <<"EMPRESA         :  ";
      pos(25,11);cout <<"No. VENTA       :  ";
      pos(25,12);cout <<"FECHA           :  ";
      pos(25,13);cout <<"CONCEPTO        :  ";
      pos(25,14);cout <<"CANTIDAD        :  ";
      pos(25,15);cout <<"VOLOR UNITARIO  :  ";
      pos(25,16);cout <<"VALOR TOTAL     :  ";
      pos(25,17);cout <<"IVA             :  ";

     pos(43,10);cin >>empresa;
     //if (strcmp(empresa,"*")==0)break;
     if (empresa[0]=='*')break;
     pos(43,11);cin >>nfact;
     pos(43,12);cin >>fecha;
     pos(43,13);cin >>concepto;
     pos(43,14);cin >>cant;
     pos(43,15);cin >>vunit;
     pos(43,16);cin >>vtotal;
     pos(43,17);cin >>iva;
     nreg++;


    }


}


void factura::reporte()
{

         limpiar
	  pos(4,1);cout <<"   INFORME GENERAL DE LAS VENTAS   ";

	  pos(3,3);cout <<"EMPRESA      F No.  FECHA   CANT. CONCEPTO    V.UNIT     VTOT.        IVA";

	  f=5;
	  for (i=1;i<nreg;i++)
          {

	   pos(3,f);cout <<empresa;
	   pos(16,f);cout <<nfact;
	   pos(23,f);cout <<fecha;
	   pos(38,f);cout <<concepto;
	   pos(27,f);cout <<cant;
	   pos(49,f);cout <<vunit;
	   pos(60,f);cout <<vtotal;
	   pos(70,f);cout <<iva;
           f++;

          }


getch();
}


void factura::finalizar()
{
 exit(0);
 }



 main()
 {

  factura fac;
  fac.acceso();
  fac.menu();
  fac.captura();
  fac.reporte();
  fac.finalizar();

  };

para descargar el código .cpp hacerlo

si te parecio de utilidad  dar “me gusta” o dale tweet en la parte de abajo

Módulos en c++

Programa que utiliza módulos para ir agregando clientes en un sistema, los módulos utiliza la estructura de struct

modulos

#include "stdio.h"
#include "conio.h"
#include "string.h"
#include "ctype.h"
#define go {gotoxy(1,24);}
struct cliente
{int codigo;
 char nombre[20];
 char apellido[20];
 char direccion[20];
 char telefono[10];
 };
struct  cliente agenda[50];
void boli (int f1,int f2, int col1,int col2);
void crear();
void modificar();
void consult();
void borrar();
buscar(int codi);
void validar(int fil,int col);
menu();
void pantalla(int fila, int columna);
char vec[5][13],cad[30];
char nombre,apellido,direccion,telefono,tel[10],dir[20],nom[30],ape[30];
int res,l=0,preg,op,n,k,r,x,opc,pg;
int i=0,j=0,codigo,cod,opcion,s,o=0;
char tecla;
void cuadro(int x1,int y1,int x2,int y2,char a1[],char a2[],char a3[],char a4[],char a5[], char a6[]);
void lineav(int x1,int y1,int x2,char a1[],char a9[],char a10[]);
void lineah(int y1,int x1,int y2,char a2[],char a7[],char a8[]);
char a1[]="º",a2[]="Í",a3[]="É",a4[]="¼",a5[]="»",a6[]="È",a7[]="Ì",a8[]="¹",a9[]="Ê",a10[]="Ë";
void main()
{
do{
clrscr();
cuadro(1,1,24,80,a1,a2,a3,a4,a5,a6);
lineah(1,3,80,a2,a7,a8);
lineah(1,22,80,a2,a7,a8);
strcpy(vec[0],"   ADICION  ");
strcpy(vec[1],"MODIFICACION");
strcpy(vec[2],"  CONSULTA  ");
strcpy(vec[3],"  BORRADO   ");
strcpy(vec[4],"   SALIR    ");
opcion=menu();
  if (opcion==0)
     crear();
     if (opcion==1)
       modificar();
     if (opcion==2)
       consult();
       if (opcion==3)
	 borrar();

}while (opcion!=4);
}




void pantalla (int fila, int columna)
{gotoxy(columna,fila);printf  ("CODIGO.....");
 gotoxy(columna,fila+1);printf("NOMBRE.....");
 gotoxy(columna,fila+2);printf("APELLIDO...");
 gotoxy(columna,fila+3);printf("DIRECCION..");
 gotoxy(columna,fila+4);printf("TELEFONO...");
}




void crear()
{
 do
 { cuadro(4,3,10,35,a1,a2,a3,a4,a5,a6);
  pantalla(5,4);
  boli(23,23,4,74);
  boli(23,23,4,68);
  boli(5,9,16,34);
  gotoxy(16,5);scanf("%d",&cod);
  if (buscar(cod)==0)
  {
   validar(16,6);
   strcpy(nom,cad);
   fflush(stdin);
   validar(16,7);
   strcpy(ape,cad);
   gotoxy(16,8);gets(dir);
   gotoxy(16,9);gets(tel);
   agenda[j].codigo=cod;
   strcpy(agenda[j].nombre,nom);
   strcpy(agenda[j].apellido,ape);
   strcpy(agenda[j].direccion,dir);
   strcpy(agenda[j].telefono,tel);
  }
  else
 { boli(5,5,16,34);
   gotoxy(16,5);printf("%d",agenda[k].codigo);
   gotoxy(16,6);printf("%s",agenda[k].nombre);
   gotoxy(16,7);printf("%s",agenda[k].apellido);
   gotoxy(16,8);printf("%s",agenda[k].direccion);
   gotoxy(16,9);printf("%s",agenda[k].telefono);
   gotoxy(4,23);printf("ESTE CODIGO YA EXISTE");
   getch();
 }
  j++;
  k=0;
   gotoxy(4,23);printf("DESEA CONTINUAR  S/N [ ]    ");
   gotoxy(26,23);res=getch();

  res=toupper(res);

  }while (res!='N');
}




menu()
{do
 {r=2;
  textbackground(0);
  for (i=0;i<5;i++)
   {if (i==o)
    {textcolor(1);
     textbackground(7);
     gotoxy(2+r,2);cprintf("%s",vec[i]);
     }
     else
      {textcolor(0);textbackground(11);
       gotoxy(2+r,2);cprintf("%s",vec[i]);}
       r+=15;
       textcolor(0);
       textbackground(11);
       switch(o)
       {
	case 0:go;gotoxy(5,21);cprintf("MODULO PARA LA ADICCION DE CLIENTES    ");
	       break;
	case 1:go; gotoxy(5,21);cprintf("MODULO PARA LA MODIFICACION DE CLIENTES");
	       break;
	case 2:go; gotoxy(5,21);cprintf("MODULO PARA LA CONSULTA DE CLIENTES    ");
	       break;
	case 3:go; gotoxy(5,21);cprintf("MODULO PARA EL BORRADO DE CLIENTES    ");
	       break;
	case 4:go; gotoxy(5,21);cprintf("MODULO PARA SALIR DEL SISTEMA       ");
	       break;
       }
      }
      tecla=getch();
       if(tecla==77)
       {if (o<4)
	 o++;
	 else
	 o=0;
       }
       if (tecla==75)
	{if (o!=0)
	 o--;
	 else
	  o=4;
	}
 }
 while (tecla!=13);
 return(o);
 }



buscar(int cod)
{
 int sw=0;
     k=0;
  while ((sw==0) && (k<j))
   {if (cod==agenda[k].codigo)
     sw=1;
     else
       k++;
    }
    return(sw);
}
void cuadro(int x1,int y1,int x2,int y2,char a1[],char a2[],char a3[],char a4[],char a5[], char a6[])
{ int p;
  for(p=x1;p<=x2;p++)
  {
    gotoxy(y1,p);cprintf(a1);
     gotoxy(y2,p);cprintf(a1);
  }
  for(p=y1;p<=y2;p++)
  {
      gotoxy(p,x1);cprintf(a2);
      gotoxy(p,x2);cprintf(a2);
   }
      gotoxy(y1,x1);cprintf(a3);
      gotoxy(y2,x2);cprintf(a4);
      gotoxy(y2,x1);cprintf(a5);
      gotoxy(y1,x2);cprintf(a6);

}

void lineav(int x1,int y1,int x2,char a1[],char a9[],char a10[])
{ int p;
  for(p=x1;p<=x2;p++)
  {
    gotoxy(y1,p);cprintf(a1);

  }
    gotoxy(y1,x1);printf(a10);
    gotoxy(y1,x2);printf(a9);
}
void lineah(int y1,int x1,int y2,char a2[],char a7[],char a8[])
{ int p;
  for(p=y1;p<=y2;p++)
  {
    gotoxy(p,x1);cprintf(a2);

  }
    gotoxy(y1,x1);printf(a7);
    gotoxy(y2,x1);printf(a8);
}


void boli (int f1, int f2, int col1, int col2)
{int i, j;
 {for (i=f1;i<=f2;i++)
   for (j=col1;j<col2;j++)
    {gotoxy(j,i);cprintf(" ");
    }
  }
}



void validar(int fil,int col)
{ int i=0;
 cad[0]=' ';
  do
 {
   do
     {

      gotoxy(fil+i,col);res=getch();
      if ((res>='a' && res<='z')||(res>='A' && res<='Z')||(res==' '))
	{
	    cad[i++]=res;
	    gotoxy(fil-1+i,col);printf("%c",res);
	}
      }
  while (res!=13);
 }
 while (cad[0] == ' ');
 cad[i]='\0';
 }



void consult()
{
do
{boli(23,23,4,78);
 boli(4,18,20,76);
 cuadro(4,9,11,23,a1,a2,a3,a4,a5,a6);
 lineah(9,7,23,a2,a7,a8);
 gotoxy(4,23);printf("DIGITE LA OBCION     [ ]");
 gotoxy(12,6);printf("CONSULTA");
 gotoxy(10,8);printf("1.GLOBAL");
 gotoxy(10,9);printf("2.INDIVIDUAL");
 gotoxy(10,10);printf("3.SALIR");
 gotoxy(26,23);op=getch();
 boli(23,23,4,78);
 boli(4,11,9,24);
 if (op=='1')
 {gotoxy(21,5);printf("CODIGO");
  gotoxy(28,5);printf("NOMBRE");
  cuadro(4,20,18,75,a1,a2,a3,a4,a5,a6);
  lineah(20,16,75,a2,a7,a8);
  lineah(20,6,75,a2,a7,a8);
  lineav(4,27,16,a1,a9,a10);
  for (n=0;n<=j;n++)
  {
    if (x<=3)
    {gotoxy(21,x+7);printf("%d",agenda[n].codigo);
      gotoxy(28,x+7);printf("%s",agenda[n].nombre);
	   x++;
     }
     else
     {gotoxy(23,17);printf("DESEA CONTINUAR S/N [ ]");
      gotoxy(26,17);preg=getch();
      if (preg=='n')
       {n=j;
       }
       else
       {
	x=0;
       }
      }
     }
   boli(17,17,23,74);
   gotoxy(23,17);printf("ESTOS SON TODOS LOS DATOS");
   getch();
  }

if (op=='2')
{do
 {
   boli(5,9,49,65);
   boli(23,23,4,78);
   cuadro(4,35,10,66,a1,a2,a3,a4,a5,a6);
   pantalla(5,36);
   gotoxy(49,5);scanf("%d",&cod);
  if (buscar(cod)!=0)
  { boli(5,9,49,65);
   gotoxy(49,5);printf("%d",agenda[l].codigo);
   gotoxy(49,6);printf("%s",agenda[l].nombre);
   gotoxy(49,7);printf("%s",agenda[l].apellido);
   gotoxy(49,8);printf("%s",agenda[l].direccion);
   gotoxy(49,9);printf("%s",agenda[l].telefono);
   gotoxy(4,23);printf("ESTOS SON LOS DATOS CONSULTADOS      ");
   getch();
 }
   else
  {gotoxy(4,23);printf("ESTE CODIGO NO EXISTE");
    getch();
  }
    l=0;
   boli(23,23,4,78);
   gotoxy(4,23);printf("DESEA CONTINUAR  S/N [ ]    ");
   gotoxy(26,23);res=getch();
   boli(23,23,4,78);
  res=toupper(res);
 }while (res!='N');
 }
 } while (op!='3');
 }



void borrar()
{
do
 {
  boli(6,20,2,78);
  cuadro(4,48,10,75,a1,a2,a3,a4,a5,a6);
  pantalla(5,49);
  boli(5,9,60,74);
  gotoxy(60,5);scanf("%d",&cod);
  if (buscar(cod)!=0)
   {
     boli(5,5,60,75);
     gotoxy(60,5);printf("%d",agenda[k].codigo);
     gotoxy(60,6);printf("%s",agenda[k].nombre);
     gotoxy(60,7);printf("%s",agenda[k].apellido);
     gotoxy(60,8);printf("%s",agenda[k].direccion);
     gotoxy(60,9);printf("%s",agenda[k].telefono);
     gotoxy(4,23);printf("ESTA SEGURO DE ELIMINAR S/N [ ]");
     gotoxy(33,23);preg=getch();
     preg=toupper(preg);
      boli(23,23,4,78);
     if (preg=='S')
	{
	if (j==k-1)
	  {
	  j--;
	  }
       else
       {
	 for (s=l;s<j;s++)
	 {
	   agenda[s]=agenda[s+1];
	 //  strcpy(agenda[s].nombre,agenda[s+1].nombre);
	 //  strcpy(agenda[s].apellido,agenda[s+1].apellido);
	 //  strcpy(agenda[s].direccion,agenda[s+1].direccion);
	 //  strcpy(agenda[s].telefono,agenda[s+1].telefono);
	}
	 j--;
       }
       //boli(23,23,4,79);
       gotoxy(4,23);printf("       DATOS BORRADOS      ");
       getch();
      }
     }
  else
   {
    boli(23,23,4,79);
    gotoxy(4,23);printf("ESTE CODIGO NO EXISTE");
    getch();
  }
   //boli(23,23,4,79);
   l=0;
   gotoxy(4,23);printf("DESEA CONTINUAR BORRANDO S/N [ ]    ");
   gotoxy(34,23);res=getch();
   res=toupper(res);
  j++;
  }
   while (res!='N');
}




/*void borrar()
{
 do
  {
    boli(6,20,2,78);
     cuadro(5,48,11,75,a1,a2,a3,a4,a5,a6);
    pantalla(6,49);
    boli(20,20,4,78);
    gotoxy(4,20);printf("DIGITE EL CODIGO DEL REGISTRO A BORRAR");

    gotoxy(60,6);scanf("%d",&cod);
    if (buscar(cod)!=0)
    {
     gotoxy(60,6);printf("%d",agenda[l].codigo);
     gotoxy(60,7);printf("%s",agenda[l].nombre);
     gotoxy(60,8);printf("%s",agenda[l].apellido);
     gotoxy(60,9);printf("%s",agenda[l].direccion);
     gotoxy(60,10);printf("%s",agenda[l].telefono);
      boli(20,20,4,78);
       //boli(23,23,4,78);
     gotoxy(4,20);printf("DESEA BORRAR ESTE REGISTRO S/N [ ]" );
     gotoxy(36,20);res=getch();
     res=toupper(res);
     boli(20,20,4,78);
     if (res=='S')
     {
     if (l== --j)
       {
       j--;
       }
       else
       {
	  for (s=l;s<j;s++)
	  {
	   agenda[s].codigo=agenda[s+1].codigo;
	   strcpy(agenda[s].nombre,agenda[s+1].nombre);
	   strcpy(agenda[s].apellido,agenda[s+1].apellido);
	   strcpy(agenda[s].direccion,agenda[s+1].direccion);
	   strcpy(agenda[s].telefono,agenda[s+1].telefono);
	   n--;
	 }
       }
//       boli(23,23,4,79);
       gotoxy(4,20);printf("REGISTRO BORRADO...PULSE ENTER PARA CONTINUAR");
       getch();
     }

   }
  else
   {
    //boli(23,23,4,79);
    boli(20,20,4,78);
    gotoxy(4,20);printf("CODIGO NO EXISTE... PULSE ENTER PARA CONTINUAR");
    getch();
  }
   // boli(23,23,4,79);
    l=0;
     boli(20,20,4,78);
    gotoxy(4,20);printf("DESEA BORRAR OTRO REGISTRO S/N [ ]");
    gotoxy(36,20);res=getch();
    res=toupper(res);
    j++;
  }
   while (res!='N');
   boli(5,20,2,78);

} */


void modificar()
{int cod;
 do
{boli(5,9,32,49);
 boli(4,9,52,69);
 boli(23,23,4,78);
 cuadro(4,19,10,50,a1,a2,a3,a4,a5,a6);
 pantalla(5,20);
 gotoxy(32,5);scanf("%d",&cod);
 if (buscar(cod)!=0)
 {do
 {gotoxy(32,6);puts (agenda[l].nombre);
  gotoxy(32,7);puts(agenda[l].apellido);
  gotoxy(32,8);puts(agenda[l].direccion);
  gotoxy(32,9);puts(agenda[l].telefono);
  cuadro(4,52,9,69,a1,a2,a3,a4,a5,a6);
  gotoxy(53,5);printf("1..NOMBRE");
  gotoxy(53,6);printf("2..APELLIDOS");
  gotoxy(53,7);printf("3..DIRECCION");
  gotoxy(53,8);printf("4..TELEFONO");
  boli(23,23,4,78);
  gotoxy(4,23);printf("ESCOJA UNA OPCION [ ]");
  gotoxy(23,23);opc=getch();
  if (opc=='1')
   {  boli(4,9,52,70);
   boli(6,6,32,49);
   validar(32,6);
   strcpy(nom,cad);
   strcpy(agenda[l].nombre,nom);
   }
      if (opc=='2')
   { boli(4,9,52,70);
     boli(7,7,32,49);
     validar(32,7);
     strcpy(ape,cad);
     strcpy(agenda[l].apellido,ape);
    }
      if (opc=='3')
   { boli(4,9,52,70);
     boli(8,8,32,49);
     gotoxy(32,8);gets(dir);
     strcpy(agenda[l].direccion,dir);
    }
    if (opc=='4')
   { boli(4,9,52,70);
     boli(9,9,32,49);
     gotoxy(32,9);gets(tel);
     strcpy(agenda[l].telefono,tel);
    }
     boli(23,23,4,78);
     gotoxy(4,23);printf("DESEA CONTINUAR S/N [ ]");
     gotoxy(25,23);pg=getch();
     pg=toupper(pg);
   } while (pg!='N');
  }
 else
 {gotoxy(60,11);printf("ESTE CODIGO NO EXISTE");
  getch();
  }
  boli(5,9,53,78);
  boli(23,23,4,78);
  gotoxy(4,23);printf("DESEA CONTINUAR CON OTRO REGISTRO S/N [ ]");
  gotoxy(43,23);preg=getch();
  preg=toupper(preg);
} while (preg!='N');
}





para descargar el código .cpp hacerlo

si te parecio de utilidad  dar “me gusta” o dale tweet en la parte de abajo

Captura datos con poo en c++

Programa que captura datos de productos . todo esta completamente modelado en clases y utiliza lista ligadas para guardar los productos

poo

#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include <io.h>
#include <stdlib.h>
#include <dos.h>
#include <ctype.h>
#include <string.h>
#include <iomanip.h>
/*********************DEFINICION DE LA CLASE*********************/
class lista
{
    struct nodoc{

	   char numero[2];
	   int edad;
	   int cedula;
	   char nombre[45];
	   char apellido[45];
	   char sexo[1];
	   struct nodou *ant_usuario;
	   struct nodoc *sig_caj;
	   struct nodoc *sig;
	   struct nodoc *enlace;
	   }nodo_caj;


     struct nodou{
	   int cedula[8];
	   char nombre[40];
	   char apellido[30];
	   float op;
	   float valor;
	   struct nodou *sig;
	   struct nodou *ant;
	   }nodo_usuario;
	   struct nodou *nn1;


     public:
	    void inicializar();
	    void adicionar_caj();
	    void adicionar_usuario();
	    void operacion();
	    void consultas();
	    void agregar();
	    void modificar();
	    void eliminar();
	    void captura(char ced_para[],int t,int x,int y);
	    void captura1(char ced_para[],int t,int x,int y);
	    void marco(int x1,int y1,int x2,int y2);
	    void cuadro(int a,int b,int c,int d);
	    void pintura();
	    struct nodoc *ptr,*p,*nn,*q;

};


void lista::inicializar()
{
  ptr=NULL;
}

void lista::operacion()
{
}
void lista::consultas()
{
}
void lista::adicionar_usuario()

{
}


void lista::captura(char cod_para[],int t,int x,int y)
{
char c=' ';
int n_caracteres=0,a=x-1;
gotoxy(x,y);
	   while(c!='\r' && n_caracteres<t)
	   {
	     c=getche();
	     a++;
	     if(!isdigit(c) && c!='\r'&& !ispunct(c))
	     {
	     gotoxy(a,y);
	     clreol();
	     a--;
	     }
	      else
	      {
	      cod_para[n_caracteres]=c;
	      n_caracteres++;
	      }
	    }
	    cod_para[n_caracteres]='\0';

}

void lista::captura1(char cod_para[],int t,int x,int y)
{
char c=' ';
int n_caracteres=0,a=x-1;
gotoxy(x,y);
	   while(c!='\r' && n_caracteres<t)
	   {
	     c=getche();
	     a++;
	     if(!isalpha(c) && c!='\r')
	     {
	     gotoxy(a,y);
	     clreol();
	     a--;
	     }
	      else
	      {
	      cod_para[n_caracteres]=c;
	      n_caracteres++;
	      }
	    }
	    cod_para[n_caracteres]='\0';

}


void lista::marco(int x1,int y1,int x2,int y2)
{
  int i;
  gotoxy(x1, y1); printf("%c",218); //Ú
  gotoxy(x2, y1); printf("%c",191); //¿
  gotoxy(x1, y2); printf("%c",192); //À
  gotoxy(x2, y2); printf("%c",217); //Ù
       for(i=(x1+1);i<=(x2-1);i++){
       gotoxy(i, y1);printf("%c",196);//Ä
       gotoxy(i, y2);printf("%c",196);}
    for(i=(y1+1);i<=(y2-1);i++){
       gotoxy(x1, i);printf("%c",179); //³
       gotoxy(x2, i);printf("%c",179);}
}


void lista::cuadro(int a,int b,int c,int d)
{
	      int f;
	     //textcolor(10);
	    // window(1,1,80,25);
	     gotoxy(a-1,b-1);
	    cprintf("É");
	    for(f=a;f<=c;f++)
	      cprintf("Í");
	       cprintf("»");
	       for(f=b;f<=d;f++){
	       gotoxy(c+1,f);
	       cprintf("º");}
	       gotoxy(a-1,d+1);
	       cprintf("È");
	     for(f=a;f<=c;f++)
	       cprintf("Í");
	       cprintf("¼");
	      for(f=b;f<=d;f++){
	      gotoxy(a-1,f);
	      cprintf("º");}
}


void lista::pintura()
{
  int u;
  //textcolor(1);
  for (u=2;u<26;u++)
  {
  /* delay (2000);*/
  gotoxy(2,u);
  cprintf("°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°");

  }
}

//***************************MENU PRINCIPAL*************************************
void main()
{
  lista obj;
  obj.inicializar();
  char op;
  do
   {
    textbackground (15);
    clrscr();
    do
     {
//      textbackground ();
      clrscr();
     // obj.pintura();
      obj.marco(10,6,75,24);
      textcolor (4);
      gotoxy(23,8);
      textcolor (6);
      cprintf("COPORACION  UNIVERSITARIA  DE  SANTANDER           ");
      gotoxy(28,10);
      textcolor (15);
      cprintf("       õõ====MENU====õõ       ");
      gotoxy (29,12);
      cprintf(" 1.ADICION DE CAJAS      \n");
      gotoxy (29,13);
      cprintf(" 2.ADICION DE USUARIO    \n");
      gotoxy (29,14);
      cprintf(" 3.OPERACION DE CAJA     \n");
      gotoxy (29,15);
      cprintf(" 4.CONSULTAS             \n");
      gotoxy (29,16);
      cprintf(" 5.SALIR                 \n");
      gotoxy (28,18);
      cprintf(" SELECCIONE OPCION====>  \n");
      textcolor (1);
      obj.cuadro(28,10,57,20);
      gotoxy (51,18);
      printf ("[");
      gotoxy (53,18);
      printf ("]");
      gotoxy (52,18);
      op=getch();sound(300);delay(100);nosound();
    }while ((op>'7')||(op<'1'));
     switch (op)
   {
	 case'1':
	 obj.adicionar_caj();
	 break;

	 case'2':
	 obj.adicionar_usuario();
	 break;

	 case'3':
	 obj.operacion();
	 break;

         case'4':
	 obj.consultas();
	 break;

         case '5':
	 break;

    }
     }while (op!='5');
      clrscr();
  }


//******************************MENU DE CAJA******************************

void lista::adicionar_caj()
{
   char op;
    clrscr();

     do{
	clrscr();
	pintura();
	//cuadro(2,2,79,23);
	cuadro(20,6,62,18);
      //	marco(4,3,77,22);
       //	marco(2,2,66,20);
       //	marco(20,15,62,18);
	//marco(20,6,62,14);
	textcolor(20);
	textcolor(20201);gotoxy(21,7);cprintf("           ====CAJA====             ");
	textcolor(25);gotoxy(21,8);cprintf("                                         ");
	gotoxy(25,9);cprintf("  1. ADICIONAR CAJA   ");
	gotoxy(25,10);cprintf(" 2. MODIFICAR CAJA       ");
	gotoxy(25,11);cprintf(" 3. ELIMINAR  CAJA       ");
	gotoxy(25,12);cprintf(" 4. SALIR                               ");
	gotoxy(25,17);cprintf("                                         ");
	gotoxy(21,14);cprintf("          ELIJA UNA OPCION               ");
	textcolor (1);
	gotoxy (48,14);
	printf ("[");
	gotoxy (50,14);
	printf ("]");
	gotoxy (49,14);
	op=getch();sound(300);delay(100);nosound();
	switch(op){
	  case '1':
		 agregar();
		   break;

	  case '2':
		modificar();
		  break;

	  case '3':
		 eliminar();
		   break;

	  case '4':break;
	    }
  }while(op!='4');
 }



void lista:: modificar()
{
}
void lista:: eliminar()
{
}



//*********************************ADICION DE CAJAS*********************************************
 void lista:: agregar()
       {
	char op;
	char nom[45],ape[45],num[2],ced[8],sex[1],ed[2];
	int sw;
	clrscr();
	do
	 {
	    do
	      {
	       clrscr();
	       sw=0;
	       gotoxy(30,9);cout<<"No DE CAJA......: ";captura(num,2,48,9);
	       q=ptr;
	       while(q!=NULL)
		{

		 if(strcmp(q->numero,num)==0){
		 marco(24,12,60,16);
		 marco(25,13,59,15);
		 gotoxy(31,14);
		 printf("ESTE No DE CAJA YA EXISTE");delay(1500);
		 sw=1;
		}
		  q=q->sig;
		  }

		  }while(sw==1);
		   gotoxy(30,10);cout<<"CEDULA..........: ";captura(ced,8,48,10);
		   gotoxy(30,11);cout<<"NOMBRE..........: ";captura1(nom,45,48,11);
		   gotoxy(30,12);cout<<"APELLIDO........: ";captura1(ape,45,48,12);
		   gotoxy(30,13);cout<<"SEXO............: ";captura1(sex,1,48,13);
		   gotoxy(30,14);cout<<"EDAD............: ";captura(ed,2,48,14);

		   nn=new nodoc;
		   strcpy(nn->numero,num);
		   nn->cedula=atof(ced);
		   strcpy(nn->nombre,nom);
		   strcpy(nn->apellido,ape);
		   strcpy(nn->sexo,sex);
		   nn->edad=atof(ed);
		   if (ptr==NULL){
		     ptr=nn;
		     p=nn;
		    }
		     else{
			  p->enlace=nn;
			  p=nn;
			}
			gotoxy(27,17);cout<<"DESEA INGRESAR OTRO NODO S/N ";
		     do{
		      op=toupper(getche());sound(300);delay(100);nosound();
		      if((op != 'S') && (op != 'N')){
			  gotoxy(55,17);
			  clreol();
			}
		      }while ((op != 'S') && (op != 'N'));
	      }while (op!='N');
	   }


para descargar el código .cpp hacerlo

si te parecio de utilidad  dar “me gusta” o dale tweet en la parte de abajo

Classe carro en c++

Programa que modela mediante una clase los componentes de un automóvil e ingresa sus características en un registro

class

#include"iostream.h"
#include"conio.h"
void cuadro(int x1,int x2,int y1,int y2) ;
const int lon=20;
class automovil{
private:
char marcacarro[20];
unsigned long numero;
int clase;
public:
void capturadatos()
{

cout<<"\nIntroduzca la marca=====>";
cin>>marcacarro;
cout<<"\nIntroduzca placa=====>";
cin>>numero;
cout<<"\nIn
troduzca modelo=====>";
cin>>clase;
}
void imprimirdatos()
{

gotoxy(5,7);cout<<"\n marca:"<<marcacarro;
gotoxy(5,8);cout<<"\n placa:"<<numero;
gotoxy(5,9);cout<<"\n modelo:"<< clase;
}
};
void cuadro(int x1,int x2,int y1,int y2)
{
  int j,i,k;
     for(j=x1;j<=x2;j++)
       {textcolor(14);
       gotoxy(j,y1);cprintf("Í");
       gotoxy(j,y2);cprintf("Í");

       }
     for(i=y1;i<=y2-1;i++)
       {
       gotoxy(x1,i);cprintf("º");
       gotoxy(x2,i);cprintf("º");
       }
     gotoxy(x1,y1);cprintf("É");
     gotoxy(x2,y1);cprintf("»");
     gotoxy(x1,y2);cprintf("È");
     gotoxy(x2,y2);cprintf("¼");
}


class carros_caros:public automovil
{
private:
char comp[lon];
char lugar[lon];
public:
void capturadatos()
{
automovil::capturadatos();
gotoxy(5,12);cout<<"\nIntroduzca nombre del comprador:";
cin>>comp;
gotoxy(5,14);cout<<"\nIntroduzca Destino:";
cin>>lugar;
}
void imprimirdatos()
{
automovil::imprimirdatos();
gotoxy(5,10);cout<<"\n comprador:"<<comp;
gotoxy(5,11);cout<<"\n destino:"<< lugar;
}
};
class carros_servicio:public automovil
{
private:
char comp[lon];
char lugar[lon];
public:
void capturadatos()
{
automovil::capturadatos();
gotoxy(5,13);cout<<"Introduzca nombre del comprador:";
cin>>comp;
gotoxy(5,15);cout<<"Introduzca destino de viaje :";
cin>>lugar;
}
void imprimirdatos()
{
automovil::imprimirdatos();

gotoxy(5,10);cout<<"\n comprador:"<<comp;
gotoxy(5,11);cout<<"\n destino:"<< lugar;
}
};
class camiones:public automovil
{
private:
char comp[lon];
char lugar[lon];
public:
void capturadatos()
{
automovil::capturadatos();
gotoxy(5,13);cout<<"Introduzca nombre del comprador:";
cin>>comp;
gotoxy(5,15);cout<<"Introduzca destino de viaje :";
cin>>lugar;
}
void imprimirdatos()
{
automovil::imprimirdatos();

gotoxy(5,10);cout<<"\n comprador:"<<comp;
gotoxy(5,11);cout<<"\n destino:"<< lugar;
}

};
void main()
{
clrscr();
carros_caros cl1,cl2;
carros_servicio csp1,csp2;
camiones cam1,cam2;



gotoxy(5,5);cout<<"\n INTRODUZCA DATOS CARROS DE CARRERA .1";
cl1.capturadatos();
gotoxy(5,5);cout<<"\n INTRODUZCA DATOS CARROS DE CARRERA .2";
cl2.capturadatos();
gotoxy(5,5);cout<<"\n INTRODUZCA DATOS CARROS DE SERVICIO PUBLICO.1";
csp1.capturadatos();
gotoxy(5,5);cout<<"\n INTRODUZCA DATOS CARROS DE SERVICIO PUBLICO .2";
csp2.capturadatos();
gotoxy(5,5);cout<<"\n INTRODUZCA  DATOS  CARGA  .1";
cam1.capturadatos();
gotoxy(5,5);cout<<"\n INTRODUZCA  DATOS   CARGA .2";
cam2.capturadatos();
//***************pantalla****************//
clrscr();
cuadro(5,46,2,4);
gotoxy(7,3);cout<<"  DATOS     CARROS    DE    LUJO    .1";
cl1.imprimirdatos();
getch();
gotoxy(7,3);cout<<"  DATOS     CARROS    DE    LUJO    .2";
cl2.imprimirdatos();
getch();
gotoxy(7,3);cout<<"  DATOS CARROS DE  SERVICIO PUBLICO .1";
csp1.imprimirdatos();
getch();
gotoxy(7,3);cout<<"  DATOS CARROS DE SERVICIO PUBLICO . 2";
csp2.imprimirdatos();
getch();
gotoxy(7,3);cout<<"  DATOS         CAMIONES            .1";
cam1.imprimirdatos();
getch();
gotoxy(7,3);cout<<"  DATOS         CAMIONES            .2";
cam2.imprimirdatos();
getch();
}

para descargar el código .cpp hacerlo

si te parecio de utilidad  dar “me gusta” o dale tweet en la parte de abajo