contoh program matrik 3x3 c++

#include <iostream>
#include <string>
using namespace std;
int main(){int i,j;
            char A[3][3]={'a','b','c','d','e','f','g','h','i'},B[3][3]={'j','k','l','m','n','o','p','q','r'};
    for (i=0;i<3;i++){
        for(j=0;j<3;j++){cout<<A[i][j]<<" ";}
        if (i==1){cout<<"  *  ";}
         else {cout<<"     ";}
        for(j=0;j<3;j++){cout<<B[i][j]<<" ";}
        if (i==1){cout<<"  =  ";}
         else {cout<<"     ";}
        for(j=0;j<3;j++){cout<<A[i][0]<<B[0][j]<<"+"<<A[i][1]<<B[1][j]<<"+"<<A[i][2]<<B[2][j]<<" ";}
        cout<<"  ";
        cout<<endl;}

    return 0;}

Post a Comment

Lebih baru Lebih lama