[ create a new paste ] login | about

Link: http://codepad.org/l3Sv2qFP    [ raw code | output | fork ]

C++, pasted on Jun 3:
#include <iostream>
#include <cstdlib>

using namespace std;

int main();
int menu(int art);
int AnhiadirArticulos();
int art=0, *codigo, *cantidad;
int Cliente(int art, int codigo[], int cantidad[]);
int Proveedor(int art, int codigo[], int cantidad[]);
int VerArticulos(int art, int codigo[], int cantidad[] );
int Transacciones(int art, int codigo[], int cantidad[] );

int menu(int art, int &codigo, int &cantidad)
{
    int opcion, main();
    system("cls");
    cout << endl << endl;
    cout << "MARQUE << 1 >> VER  ARTICULOS" << endl;
    cout << "MARQUE << 2 >> TRANSACCIONES" <<  endl << endl;
    cout << "MARQUE UNA OPCION PARA CONTINUAR   --> ";
    cin >> opcion;
    system("cls");

    switch ( opcion )
    {
    case 1:
        VerArticulos( art, &codigo, &cantidad );
        break;
    case 2:
        Transacciones(art, &codigo, &cantidad);
        break;
    default:
        cout << "MARCACION INCORRECTA, SE CERRARA EL PROGRAMA";
        cin.get();
        cin.get();
        system("PAUSE");
    }

    return 0;
}

int AnhiadirArticulos()
{
    system("cls");

    cout << endl << endl;
    cout<<"CON CUANTOS ARTICULOS INICIA EL ALMACEN   --> ";
    cin>>art;

    int codigo[art];
    int cantidad[art];

    for ( int i=0; i<art; i++ )
    {
        system("cls");

        cout << endl << endl;
        cout << "INGRESE EL ARTICULO   --> " << i+1 << endl;
        cout << "             CODIGO   --> ";
        cin >> codigo[i];
        cout << "             CANTIDAD --> ";
        cin >> cantidad[i];
    }

    VerArticulos( art, codigo, cantidad);

    return 0;
}

int VerArticulos(int art, int codigo[], int cantidad[])
{
    system("cls");

    cout << endl << endl;
    cout << "CODIGO\t\tCANTIDAD" << endl << endl;

    for ( int i=0; i<art; i++ )
    {
        cout << "  " << codigo[i] << "\t\t " << cantidad[i] << endl;
    }

    cout << endl << endl;
    cout << "PRESIONE UNA TECLA PARA IR AL MENU   --> ";
    cin.get();
    cin.get();

    menu(art,*codigo,*cantidad);

    return 0;
}

int Transacciones(int art, int codigo[], int cantidad[] )
{
    int op, opc;
    int cod, cantrecibida, cantvendida;
    system("cls");

    do
    {
        system("cls");
        cout << endl << endl;
        cout << "MARQUE << 1 >> SI ES PROVEERDOR" << endl;
        cout << "MARQUE << 2 >> SI ES UN CLIENTE" << endl << endl;
        cout << "MARQUE UNA OPCION PARA CONTINUAR  --> ";
        cin >> op;

        if ( op == 1 )
        {
            system("cls");
            cout << endl << endl;
            cout << "CODIGO    --> ";
            cin >> cod;
            cout << "CANTIDAD  --> ";
            cin >> cantrecibida;

            for ( int j=0; j<art; j++ )
            {
                if ( cod == codigo[j] )
                {
                    cantidad[j] = cantidad[j] + cantrecibida;
                    cout << endl << endl << "TRANSACCION EXITOSA, EXISTEN "
                    << cantidad[j] << " UNIDADES DEL ARTICULO" << endl << endl;
                }
                else
                {
                    cantidad[j+art] = cantidad[j+art] + cantrecibida;
                }
            }
        }
        else if ( op == 2 )
        {
            system("cls");
            cout << endl << endl;
            cout << "CODIGO    --> ";
            cin>>cod;
            cout << "VENDIDOS  --> ";
            cin >> cantvendida;

            for ( int i=0; i<art; i++ )
            {
                if ( cod == codigo[i] )
                {
                    cantidad[i] = cantidad[i] - cantvendida;
                    cout << endl << endl << "TRANSACCION EXITOSA, QUEDAN "
                    << cantidad[i] << " UNIDADES DEL ARTICULO" << endl << endl;
                }
            }
        }
        else
        {
            cout << "MARCACION INCORRECTA, SE CERRARA EL PROGRAMA";
            cin.get();
            cin.get();
            system("PAUSE");
        }
        cout << endl;
        cout << "MARQUE << 1 >> HACER OTRA TRANSACCION" << endl;
        cout << "MARQUE << 2 >> TERMINAR TRANSACCIONES" << endl << endl;
        cout << "MARQUE UNA OPCION PARA CONTINUAR --> ";
        cin>>opc;
    }
    while ( opc != 2 );

    menu(art,*codigo,*cantidad);

    return 0;
}

int main()
{
    AnhiadirArticulos();

    return 0;
}


Output:
1
2
3
In function 'int AnhiadirArticulos()':
Line 52: error: ISO C++ forbids variable-size array 'codigo'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: