Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define MAX 100
- int main() {
- int a[MAX][MAX];
- int b[MAX][MAX];
- int soDong, soCot, soDong1, soCot1;
- int tong = 0;
- cout << "NHap so dong:";
- cin >> soDong;
- cout << "nhap so cot :";
- cin >> soCot;
- for (int i = 0; i < soDong; i++) {
- for (int j = 0; j < soCot; j++) {
- cout << "Nhap a[" << i+1<< "][" << j+1 << "]";
- cin >> a[i][j];
- }
- }
- cout << "\t" << "MA TRAN A" << endl;
- for (int i = 0; i < soDong; i++) {
- for (int j = 0; j < soCot; j++) {
- cout <<"\t"<< a[i][j];
- }
- cout << endl;
- }
- cout << "NHap so dong:";
- cin >> soDong1;
- cout << "nhap so cot :";
- cin >> soCot1;
- for (int i = 0; i < soDong1; i++) {
- for (int j = 0; j < soCot1; j++) {
- cout << "Nhap a[" << i+1<< "][" << j+1 << "]";
- cin >> b[i][j];
- }
- }
- cout << "\t" << "MA TRAN B" << endl;
- for (int i = 0; i < soDong1; i++) {
- for (int j = 0; j < soCot1; j++) {
- cout << "\t" << b[i][j];
- }
- cout << endl;
- }
- // Nhanma tran
- cout << "Nhan 2 ma tran" << endl;
- for (int i = 0; i < soDong; i++)
- for (int j = 0; j<soCot1; j++)
- {
- for(int k = 0; k < soDong1; k++)
- for(int l=0;l<soCot;l++){
- tong = tong + a[i][l ] * b[k][j];
- }
- cout << endl;
- }
- for (int i = 0; i < soDong;i++) {
- for (int j = 0; j < soCot; j++) {
- cout << "\t" <<tong;
- }
- cout << endl;
- }
- system("pause>NULL");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement