Foros del Web » Programación para mayores de 30 ;) » C/C++ »

Comentar Programa

Estas en el tema de Comentar Programa en el foro de C/C++ en Foros del Web. Necesito ayuda para comentar este programa. alguien me ayudaría a comentarlo @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código C++: Ver original #include<fstream> #include<iostream> #include<stdlib.h> #include<conio.h> #include<string.h>   using namespace ...
  #1 (permalink)  
Antiguo 01/05/2013, 22:42
 
Fecha de Ingreso: marzo-2013
Mensajes: 2
Antigüedad: 11 años, 1 mes
Puntos: 0
Pregunta Comentar Programa

Necesito ayuda para comentar este programa.
alguien me ayudaría a comentarlo



Código C++:
Ver original
  1. #include<fstream>
  2. #include<iostream>
  3. #include<stdlib.h>
  4. #include<conio.h>
  5. #include<string.h>
  6.  
  7. using namespace std;
  8. int reg = 0, indice = 0, i; char opcion; bool banderita = true, bandera = true;
  9.  
  10. struct Biblioteca{
  11.     char nombre[30], editorial[30], autor[20];
  12.     int id, edicion;
  13. }B[5];
  14.  
  15.  
  16. void Seleccion(){
  17.     do{
  18.        opcion=toupper(getch());
  19.   }while(!isalpha(opcion));
  20. }
  21.  
  22.  
  23. int Buscar(){
  24.    system("cls");
  25.    int auxcarnet;
  26.    bool band = true;
  27.    cout << "Por favor ingrese el numero del registro que intenta modificar: \n";
  28.    cin >> auxcarnet;
  29.    for(i = 0; i <= reg-1; i++)
  30.       {
  31.       if(auxcarnet == B[i].id)
  32.          {
  33.          cout << "\n";
  34.          cout << "ID del Libro: " <<  B[i].id << endl;
  35.          cout << "Nombre del Libro: " << B[i].nombre << endl;
  36.          cout << "Autor del Libro: " << B[i].autor << endl;
  37.          cout << "Edicion del Libro: " << B[i].edicion << endl;
  38.          cout << "Editorial del Libro: " << B[i].editorial << endl;
  39.          cout << "\n\n\n";
  40.          band = false;
  41.         }
  42.     }
  43.     if(band == true)
  44.     cout << "ID no existente! \a";
  45.     getch();
  46. }
  47.  
  48.  
  49. void eliminar(){
  50.             system("cls");
  51.             indice = Buscar();
  52.                 cout << "Seguro que desea borrar este registro s/n\n";
  53.                 Seleccion();
  54.                  if(opcion == 'S'){
  55.                     for(int j = indice; j <= reg-1; j++)
  56.                          B[j] = B[j+1];
  57.                         reg--;
  58.                         cout << "Registro borrado" << endl;
  59.                          getch();}
  60. }
  61.  
  62.  
  63. void modificar()
  64. {
  65.    system("cls");
  66.    int auxcarnet;
  67.    bool band = true;
  68.    cout << "Por favor ingrese el numero del registro que intenta modificar: \n";
  69.    cin >> auxcarnet;
  70.    for(i = 0; i <= reg-1; i++)
  71.       {
  72.       if(auxcarnet == B[i].id)
  73.          {
  74.          cout << "\n";
  75.          cout << "ID del Libro: " <<  B[i].id << endl;
  76.          cout << "Nombre del Libro: " << B[i].nombre << endl;
  77.          cout << "Autor del Libro: " << B[i].autor << endl;
  78.          cout << "Edicion del Libro: " << B[i].edicion << endl;
  79.          cout << "Editorial del Libro: " << B[i].editorial << endl;
  80.          cout << "\n\n\n";
  81.          band = false;
  82.          cout << "\tQue desea Modificar:\n";
  83.          cout << "\tA.Nombre\n";
  84.          cout << "\tB.Autor\n";
  85.          cout << "\tC.Edicion\n";
  86.          cout << "\tD.Editorial\n";
  87.          cout << "\tE.Salir\n";
  88.          cout << "Ingresa la Opcion:\n";
  89.          do
  90.            {
  91.            do
  92.              {
  93.              opcion=toupper(getch());
  94.              }
  95.            while(!isalpha(opcion));
  96.            }
  97.          while (opcion < 'A' || opcion > 'E');
  98.          switch(opcion)
  99.             {                                                                    
  100.                 case 'A': cout << "\nPor Favor ingrese el nuevo Nombre del Libro:\n";
  101.                           cin >> B[i].nombre;
  102.                           break;
  103.                
  104.                 case 'B': cout << "\nPor Favor ingrese el nuevo Autor del Libro:\n";
  105.                           cin >> B[i].autor;
  106.                           break;
  107.                          
  108.                 case 'C': cout << "\nPor Favor ingrese la nueva Edicion del Libro:\n";
  109.                           cin >> B[i].edicion;
  110.                           break;
  111.                          
  112.                 case 'D': cout << "\nPor Favor Ingrese la nueva Editorial del Libro:\n";
  113.                           cin >> B[i].editorial;
  114.                           break;
  115.                                                    
  116.                 case 'E': break;
  117.  
  118.             }
  119.          }
  120.       }
  121.    if(band == true)
  122.    cout << "ID del Libro No Admitido, Intentelo otra vez o verifique si hay errores! \a";
  123.    getch();
  124. }
  125.  
  126.  
  127. void grabar()
  128. {
  129.     fstream archivo;
  130.     archivo.open("DatosBiblioteca.txt", ios::out);
  131.     for(i = 0; i < reg; i++)
  132.     {
  133.     if(i == reg-1)
  134.          {
  135.          archivo << B[i].id << " " << B[i].nombre << " " <<  B[i].autor << " " << B[i].edicion << " " << B[i].editorial << " ";
  136.          }
  137.     else{
  138.          archivo << B[i].id << " " << B[i].nombre << " " <<  B[i].autor << " " << B[i].edicion << " " << B[i].editorial << " " << endl;
  139.          }
  140.     }
  141.     archivo.close();
  142. }
  143.  
  144.  
  145. void registrar()
  146. {
  147. do{
  148.    system("cls");
  149.    if(reg == 5)
  150.           {
  151.            system("cls");
  152.            cout << "Solo se pueden almacenar 5 registros!\a\n\n";
  153.            getch();
  154.            opcion = 'n';
  155.            break;
  156.           }
  157.    cout << "Ingrese ID del Libro: \n";
  158.    cin >> B[reg].id;
  159.    for(i = 0; i<=reg-1;i++)
  160.        {
  161.        if(B[reg].id == B[i].id)
  162.             {
  163.             cout << "Este ID ya existe por favor ingrese otro\n";
  164.             system("pause");
  165.             banderita = false;
  166.             }  
  167.        }
  168.    if(banderita == false)
  169.        {
  170.        banderita = true;
  171.        continue;
  172.        }
  173.    cout << "Ingrese el nombre del Libro: \n";
  174.    cin >> B[reg].nombre;
  175.    cout << "Ingrese el Autor del Libro: \n";
  176.    cin >> B[reg].autor;
  177.    cout << "Ingrese la Edicion del Libro: \n";
  178.    cin >> B[reg].edicion;
  179.    cout << "Ingrese la Editorial del Libro: \n";
  180.    cin >> B[reg].editorial;
  181.    cout << "\n";
  182.    cout << "Desea almacenar otro registro s/n \n";
  183.    reg++;
  184.    do
  185.       {
  186.       opcion = toupper (getch());
  187.       }
  188.    while(!isalpha(opcion));
  189.    }
  190. while(opcion != 'N');
  191. }
  192.  
  193. void leer()
  194. {
  195.    fstream archivo;
  196.    archivo.open("DatosBiblioteca.txt", ios::in);
  197.    if(archivo.fail())
  198.       {
  199.       fstream archivo;
  200.       archivo.open("DatosBiblioteca.txt", ios::out);
  201.       archivo.close();
  202.       cout << "Archivo no existente! Programa creara una para usted\a";
  203.       getch();
  204.       }
  205.    else
  206.       {
  207.       while(!archivo.eof())
  208.          {
  209.          archivo >> B[reg].id >> B[reg].nombre >>  B[reg].autor >> B[reg].edicion >> B[reg].editorial;
  210.          if(archivo == NULL)
  211.          break;
  212.          reg++;
  213.          }
  214.       }
  215.    archivo.close();
  216. }
  217.  
  218.  
  219. void mostrar()
  220. {
  221.    system("cls");
  222.    for(i = 0; i <= reg-1; i++)
  223.       {
  224.       cout << "ID del Libro: " <<  B[i].id << endl;
  225.       cout << "Nombre del Libro: " << B[i].nombre << endl;
  226.       cout << "Autor del Libro: " << B[i].autor << endl;
  227.       cout << "Edicion del Libro: " << B[i].edicion << endl;
  228.       cout << "Editorial del Libro: " << B[i].editorial << endl;
  229.       cout << "\n";
  230.       }
  231.    getch();
  232. }
  233.    
  234.  
  235. int main(){
  236.    leer();
  237.    do{
  238.        system("cls");
  239.        cout<< "Elija una opcion:\n\n";
  240.        cout<< "A.Registrar\n";
  241.        cout<< "B.Mostrar\n";
  242.        cout<< "C.Modificar\n";
  243.        cout<< "D.Eliminar\n";
  244.        cout<< "E.Salir\n\n";
  245.        do{
  246.            Seleccion();
  247.        }while (opcion < 'A' || opcion > 'E');
  248.        switch(opcion){
  249.                 case 'A': registrar(); break;
  250.                 case 'B': mostrar(); break;
  251.                 case 'C': modificar(); break;
  252.                 case 'D': eliminar(); break;
  253.                 case 'E': break;
  254.        }
  255.        grabar();
  256.    }while(opcion != 'E');
  257.    system("pause");
  258.    return 0;
  259. }
  #2 (permalink)  
Antiguo 02/05/2013, 07:53
 
Fecha de Ingreso: julio-2012
Mensajes: 375
Antigüedad: 11 años, 9 meses
Puntos: 28
Respuesta: Comentar Programa

Los comentarios son algo personal de cada uno. Cada persona tiene su estilo y sus manias...
  #3 (permalink)  
Antiguo 02/05/2013, 19:21
 
Fecha de Ingreso: enero-2012
Ubicación: Buenos Aires
Mensajes: 745
Antigüedad: 12 años, 3 meses
Puntos: 35
Respuesta: Comentar Programa

"Comentá lo que el código no pueda decir por si mismo..."

Etiquetas: c++, comentar, estructura
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:19.