Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // zadanie 7. (dwuwymiarowe)
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int** utworz1(const unsigned n, const unsigned m)
- {
- int** tablica = new int*[n];
- for(unsigned i = 0; i < n; ++i)
- {
- tablica[i] = new int[m];
- for(unsigned j = 0; j < m; ++j)
- tablica[i][j] = rand() % 11;
- }
- return tablica;
- }
- void wypisz(int** tab, const unsigned n, const unsigned k)
- {
- for(unsigned i = 0; i < n; ++i)
- {
- for(unsigned j = 0; j < k; ++j)
- cout << tab[i][j] << '\t';
- cout << endl;
- }
- }
- bool iloczyn_macierzy(int** macierz1, int** macierz2, const unsigned w1, const unsigned k1, const unsigned w2, const unsigned k2, int**& wynik)
- {
- if(k1 != w2)
- return false;
- // tworzymy macierz o wymiarach w1 na k2
- int suma;
- wynik = utworz1(w1, k2);
- for(unsigned i = 0; i < w1; ++i)
- for(unsigned j = 0; j < k2; ++j)
- {
- suma = 0;
- for(unsigned x = 0; x < k1; ++x)
- suma += macierz1[i][x] * macierz2[x][j];
- wynik[i][j] = suma;
- }
- return true;
- }
- int main()
- {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment