Ma’lumotlar tuzilmasi va algoritmi
F.I.SH._Akmalbek Jumaniyozov
Guruh: 911-21
Amaliyot: 1-amaliyot
Misol: 8-savol
Dasturlash tili: C++
Savol: Matritsani matritsaga ko‘paytiring.
#include
using namespace std;
void MultiplyWithOutAMP() {
int a[3][2] = {{1, 4}, {2, 5}, {3, 6}};
int b[2][3] = {{7, 8, 9}, {10, 11, 12}};
int product[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
for (int row = 0; row < 3; row++) {
for (int col = 0; col < 3; col++) {
// Mahsulot satrini, ustunini olish uchun A qatorni B ustunga ko'paytirish.
for (int inner = 0; inner < 2; inner++) {
product[row][col] += a[row][inner] * b[inner][col];
}
std::cout << product[row][col] << " ";
}
std::cout << "\n";
}
}
int main() {
MultiplyWithOutAMP();
getchar();
return 0;
}
Do'stlaringiz bilan baham: |