Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<class T>
- typedef struct macierz{
- T Rekord;
- int wysokoscMacierzyKwadratowej;
- void MacierzNowa(int wysokosc){
- MacierzUsun();
- wysokoscMacierzyKwadratowej = wysokosc;
- Rekord = new T *[wysokoscMacierzyKwadratowej];
- for(int i(0); i<wysokoscMacierzyKwadratowej; i++)
- Rekord[i] = **new T[wysokoscMacierzyKwadratowej];**
- MacierzResetuj();
- }
- void MacierzUsun(){
- if(Rekord != NULL){
- for(int i(0); i< wysokoscMacierzyKwadratowej; i++)
- delete Rekord[i];
- delete Rekord;
- Rekord = NULL;
- }}
- void MacierzResetuj(){
- for(int i(0) ; i < wysokoscMacierzyKwadratowej ; i++ )
- for(int j(0) ; j < wysokoscMacierzyKwadratowej ; j++)
- Rekord[i][j] = 0;
- }
- void MacierzZapisz(T wartosc, int wiersz, int kolumna){
- Rekord[wiersz][kolumna] = wartosc;
- }
- T SumaWiersza(int wiersz){
- T suma(0);
- for(int i(0); i < wysokoscMacierzyKwadratowej; i++)
- suma+=Rekord[wiersz][i];
- return suma;
- }
- T SumaMacierzy(){
- T suma(0);
- for(int i(0), i < wysokoscMacierzyKwadratowej; i++)
- suma+=SumaWiersza(i);
- return suma;
- }
- };
- template<class T>::macierz(){
- wysokoscMacierzyKwadratowej = 0;
- Rekord = NULL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement