rozwiazanie isq,
[ Pobierz całość w formacie PDF ]
// <?php//======================================================================#include <iostream>//----------------------------------------------------------------------using namespace std;//======================================================================class K;//----------------------------------------------------------------------K operator/(const double, const K& aObjK );//======================================================================class K{private:double** m_Tab2D;const unsigned int m_uSize;public:// uzupe?nij brakuj?ce konstruktoryK():m_uSize(5){m_Tab2D = new double*[m_uSize];for( unsigned int i = 0; i < m_uSize; ++i ){m_Tab2D[i] = new double[m_uSize];for( unsigned int k = 0; k < m_uSize; ++k )m_Tab2D[i][k] = 1.0f;}}~K(){for( unsigned int i = 0; i < m_uSize; ++i )delete [] m_Tab2D[i];delete [] m_Tab2D;}K(const K& aCopy ):m_uSize(aCopy.m_uSize){m_Tab2D = new double*[m_uSize];for( unsigned int i = 0; i < m_uSize; ++i ){m_Tab2D[i] = new double[m_uSize];for( unsigned int k = 0; k < m_uSize; ++k )m_Tab2D[i][k] = aCopy.m_Tab2D[i][k];}cout << "1) Konstrukor Kop = "; this->wyswietl();}void wyswietl( ){//for( unsigned int j = 0; j < m_uSize; ++j){for( unsigned int i = 0; i < m_uSize; ++i )cout << m_Tab2D[0][i] << " " ;cout << endl;//}cout << "==========================" << endl;}// uzupelnij o brakujace skladowe funkcje operatoroweK& operator=(const K& aObjK );K& operator=(const double a_dVal );K operator-(const K& aObjK );K operator*( const int a_nVal );K operator*( const double a_dVal );K operator-();operator double();friend K operator/(const double a_dVal, const K& aObjK );// operatory cz.2static void* operator new[]( size_t tNbOfBytes );static void operator delete[]( void* pMemAdress );K& operator-= (const K& objK );K& operator/= (const double& dValue );K& operator*= (const K& objK );bool operator!=(const K& objK );double& operator()(unsigned int sX, unsigned int sY);K& operator--();K operator++(int);};//----------------------------------------------------------------------//======================================================================//----------------------------------------------------------------------K& K::operator--(){for( unsigned int i = 0; i < m_uSize; ++i ){for( unsigned int k = 0; k < m_uSize; ++k ){--m_Tab2D[i][k];}}return *this;}//----------------------------------------------------------------------K K::operator++(int){K sTmp(*this);for( unsigned int i = 0; i < m_uSize; ++i ){for( unsigned int k = 0; k < m_uSize; ++k ){++m_Tab2D[i][k];}}return sTmp;}//----------------------------------------------------------------------double& K::operator()( unsigned int sX, unsigned int sY){if( sX >= m_uSize ) sX = m_uSize - 1;if( sY >= m_uSize ) sY = m_uSize - 1;return m_Tab2D[sY][sX];}//----------------------------------------------------------------------bool K::operator!=(const K& objK ){for( unsigned int i = 0; i < m_uSize; ++i ){for( unsigned int k = 0; k < m_uSize; ++k ){if( m_Tab2D[i][k] != objK.m_Tab2D[i][k] )return true;}}return false;}//----------------------------------------------------------------------K& K::operator-= (const K& objK ){for( unsigned int i = 0; i < m_uSize; ++i ){for( unsigned int k = 0; k < m_uSize; ++k ){m_Tab2D[i][k] -= objK.m_Tab2D[i][k];}}return *this;}//----------------------------------------------------------------------K& K::operator/= (const double& dValue ){for( unsigned int i = 0; i < m_uSize; ++i ){for( unsigned int k = 0; k < m_uSize; ++k ){m_Tab2D[i][k] /= (double)(dValue);}}return *this;}//----------------------------------------------------------------------K& K::operator*= (const K& objK ){for( unsigned int i = 0; i < m_uSize; ++i ){for( unsigned int k = 0; k < m_uSize; ++k ){m_Tab2D[i][k] *= objK.m_Tab2D[i][k];}}return *this;}//----------------------------------------------------------------------void* K::operator new[]( size_t tNbOfBytes ){std::cout << "Dziala operator K::new[] iloscBajtow= " << (unsigned long)(tNbOfBytes) << std::endl;return ::new unsigned char[tNbOfBytes];}//----------------------------------------------------------------------void K::operator delete[]( void* pMemAdress ){std::cout << "Dziala operator K::delete[]" << std::endl;if( pMemAdress )delete [] (unsigned char*)(pMemAdress);}//----------------------------------------------------------------------//======================================================================K::operator double(){double sMaxVal = -1e55;for( unsigned int i = 0; i < m_uSize; ++i ){for( unsigned int k = 0; k < m_uSize; ++k ){double& sItem = m_Tab2D[i][k];if( sItem > sMaxVal )sMaxVal = sItem;}}return sMaxVal;}//----------------------------------------------------------------------K K::operator-(){K sTmp(*this);for( unsigned int i = 0; i < m_uSize; ++i )for( unsigned int k = 0; k < m_uSize; ++k ){sTmp.m_Tab2D[i][k] = -sTmp.m_Tab2D[i][k];}return sTmp;}//----------------------------------------------------------------------K& K::operator=(const double a_dVal ){for( unsigned int i = 0; i < m_uSize; ++i )for( unsigned int k = 0; k < m_uSize; ++k )m_Tab2D[i][k] = a_dVal;return *this;}//----------------------------------------------------------------------K operator/(const double a_dVal, const K& aObjK ){K sTmp(aObjK);for( unsigned int i = 0; i < aObjK.m_uSize; ++i )for( unsigned int k = 0; k < aObjK.m_uSize; ++k ){double& sItem = sTmp.m_Tab2D[i][k];if( sItem != 0.0)sItem = a_dVal / sItem;}return sTmp;}//----------------------------------------------------------------------K& K::operator=(const K& aObjK ){if( &aObjK != this )for( unsigned int i = 0; i < m_uSize; ++i )for( unsigned int k = 0; k < m_uSize; ++k )m_Tab2D[i][k] = aObjK.m_Tab2D[i][k];return *this;}//----------------------------------------------------------------------K K::operator-(const K& aObjK ){K sTmp(*this);for( unsigned int i = 0; i < m_uSize; ++i )for( unsigned int k = 0; k < m_uSize; ++k )sTmp.m_Tab2D[i][k] -= aObjK.m_Tab2D[i][k];return sTmp;}//----------------------------------------------------------------------K K::operator*( const int a_nVal ){return this->operator*( (const double) a_nVal );}//----------------------------------------------------------------------K K::operator*( const double a_dVal ){K sTmp(*this);for( unsigned int i = 0; i < m_uSize; ++i )for( unsigned int k = 0; k < m_uSize; ++k )sTmp.m_Tab2D[i][k] *= (double)(a_dVal);return sTmp;}//======================================================================void wyswietl(K& objA, K& objB, K& objC ){//prze?adowanie operatora strumienia wychodz?cego <<cout << objA << endl << objB << endl << objC << endl;cout << "---------------------------------------" << endl;}//======================================================================int main(){K a, b(a), c(b);cout << "1) " << endl; ::wyswietl( a, b, c );K* newK = new K[6];delete [] newK;a -= b;cout << "2) " << endl; ::wyswietl( a, b, c );c /= -9.5;cout << "3) " << endl; ::wyswietl( a, b, c );c *= b;cout << "4) " << endl; ::wyswietl( a, b, c );if( c != a )cout << "C != A " << endl;elsecout << " C == A " << endl;cout << "5) " << endl; ::wyswietl( a, b, c );c(3,4) = -0.74;cout << "6) " << endl; ::wyswietl( a, b, c );c *= ---a ;cout << "7) " << endl; ::wyswietl( a, b, c );a *= b++;cout << "8) " << endl; ::wyswietl( a, b, c );return 0;}//======================================================================//======================================================================// ?>
[ Pobierz całość w formacie PDF ]
Tematy
- Indeks
- Rozwiązania przykładowych zadań do I kolokwium, RZECZY, Z PENA, Obwody i sygnały - All in One, Obwody i sygnały - All in One, Zadania, Obwody prądu stałego
- rozwiazania 2009 PP, Matury, Matematyka PP + klucze
- Rozwiązanie zadania egzaminacyjnego numer 2, Egzamin Zawodowy i zaliczenia
- Rozwiązanie umowy o pracę przez pracownika, studia prawnicze, 4 rok, Prawo Pracy
- Rozwiązania S1 S2 S4 S5 S6, Nowy sprawdzian szóstoklasisty 2015
- Rozwiązania z forum, Biotechnologia PWR, Semestr 3, Chemia fizyczna - ćwiczenia (Wójcik), Kolokwium II
- Ruby Praktyczne skrypty ktore rozwiaza trudne problemy, ebooki, fragmenty, helion
- Rodzaje hal stalowych oraz ich rozwiązania konstrukcyjne, Nauka, Budownictwo przemysłowe
- Rozwiązania modernizacyjne dla bram segmentowych Hormann PL, Bramy Garażowe
- Rozwiązywanie problemów z błędami systemu Windows, Komputery, WinXP dla expertów
- zanotowane.pl
- doc.pisz.pl
- pdf.pisz.pl
- pomorskie.pev.pl