Keresés

Új hozzászólás Aktív témák

  • amargo

    addikt

    válasz manrick #209 üzenetére

    struct matrix
    {
    int** pData;
    int o;
    int s;
    };
    bool GetMatrix(matrix &pMatrix)
    {
    pMatrix.pData = new int*[ pMatrix.o ];
    if(!pMatrix.pData)
    return false;
    for(int i = 0; i < pMatrix.o; i++)
    {
    pMatrix.pData[ i ] = new int[ pMatrix.s ];
    if(!pMatrix.pData[ i ])
    return false;
    }
    return true;
    }//bool GetMatrix(matrix &pMatrix)


    Esetleg valami ilyesmire gondoltál csak string.el?
    szerk: kimaradt..
    main()
    {

    bool tBool = GetMatrix( pMatrix );
    if(!tBool)
    {
    cout << ''Hiba a matrix letrehozesanal!'' << endl;
    return false;
    }
    ifstream x(filenm.c_str());
    if (x.fail()){
    cout << ''A megadott fajlt nem talalom!'';
    return false;
    }
    //Beolvassuk/kiírjuk a tömb hosszát
    x >> pMatrix.o;
    x >> pMatrix.s;
    for(int i = 0; i < pMatrix.o; i++)
    for(int j = 0; j < pMatrix.s; j++)
    x >> pMatrix.pData[ i ][ j ];

    }
    ...

    Csak ez szóközzel elválaszotott szanvanként olvassa fel.. tehát amúgy le kell kezelned.


    [Szerkesztve]

    “The workdays are long and the weekend is short? Make a turn! Bike every day, bike to work too!”

Új hozzászólás Aktív témák