«یا اللهُ یا رَبِّ یا حَیُّ یا قَیّوم یا ذَالجَلالِ وَ الاکرام اَسئَلُکَ بِاسمِکَ اَلعَظیم اَلاَعظَم اَن تَرزُقَنی رِزقاً حَلالاً طَیِّباً بِرَحمَتِکَ الواسِعَه یا اَرحَمَ الرّاحِمِین.»
برنامه ضرب دو ماتریس با استفاده از ارسال ماتریس به تابع در زبان سی پلاس پلاس :: گیم اور _ بازیسازی با unity + مطالب متفرقه

گیم اور _ بازیسازی با unity + مطالب متفرقه

آموزش های علمی با اجازه ی خدا تقدیم به هرکس خدا بخواد

آموزش های علمی با اجازه ی خدا تقدیم به هرکس خدا بخواد

به نام خدا
--
گروه قدیم ما promakers.ir یا پرومیکرز بود که بالای هزار اموزش توش ساخته بودم به اسم sajjad3011 ولی حیف ادمین سایتش عوض کرد
حالا سوالی بود کاری بود این شمارمه

قدیمیا دلم براتون تنگ شده... فقط معرفی کنید توی پیامک یا تماس یاد بیارید.
اگه جواب ندادم شاید موقعیت نداشته باشم.
بگید توی پیام از بچه های پرومیکرز هستید.

---
سوالی بود بذارید
نظر خصوصی نذارید
پاسخش سخته
دوست داشتید شماره بذارید تو واتساپ یا ایتا یا .... گروه بزنیم.
09358077198

بایگانی
پیوندها

gameover.blog.ir



#include <iostream>
using namespace std;
void take_data(int a[][10], int b[][10], int r1,int c1, int r2, int c2);
void multiplication(int a[][10],int b[][10],int mult[][10],int r1,int c1,int r2,int c2);
void display(int mult[][10], int r1, int c2);
int main()
{
    int a[10][10], b[10][10], mult[10][10], r1, c1, r2, c2, i, j, k;
    cout << "Enter rows and columns for first matrix: ";
    cin >> r1 >> c1;
    cout << "Enter rows and columns for second matrix: ";
    cin >> r2 >> c2;

/* If colum of first matrix in not equal to row of second matrix, asking user to enter the size of matrix again. */

    while (c1!=r2)
    {
        cout << "Error! column of first matrix not equal to row of second." << endl;
        cout << "Enter rows and columns for first matrix: ";
        cin >> r1 >> c1;
        cout << "Enter rows and columns for second matrix: ";
        cin >> r2 >> c2;
    }
    take_data(a,b,r1,c1,r2,c2);  /* Function to take matrices data */
    multiplication(a,b,mult,r1,c1,r2,c2); /* Function to multiply two matrices. */
    display(mult,r1,c2); /* Function to display resultant matrix after multiplication. */
    return 0;
}

void take_data(int a[][10], int b[][10], int r1,int c1, int r2, int c2)
{
    int i,j;
    cout << endl << "Enter elements of matrix 1:" << endl;
    for(i=0; i<r1; ++i)
    for(j=0; j<c1; ++j)
    {
        cout << "Enter element a" << i+1 << j+1 << " : ";
        cin >> a[i][j];
    }

    cout << endl << "Enter elements of matrix 2:" << endl;
    for(i=0; i<r2; ++i)
    for(j=0; j<c2; ++j)
    {
        cout << "Enter element b" << i+1 << j+1 << " : ";
        cin >> b[i][j];
    }
}

void multiplication(int a[][10],int b[][10],int mult[][10],int r1,int c1,int r2,int c2)
{
    int i,j,k;
/* Initializing elements of matrix mult to 0.*/
    for(i=0; i<r1; ++i)
    for(j=0; j<c2; ++j)
    {
       mult[i][j]=0;
    }
/* Multiplying matrix a and b and storing in array mult. */
    for(i=0; i<r1; ++i)
    for(j=0; j<c2; ++j)
    for(k=0; k<c1; ++k)
    {
        mult[i][j]+=a[i][k]*b[k][j];
    }
}

void display(int mult[][10], int r1, int c2)
{
    int i, j;
    cout << endl << "Output Matrix: " << endl;
    for(i=0; i<r1; ++i)
    for(j=0; j<c2; ++j)
    {
        cout << " " << mult[i][j];
        if(j==c2-1)
            cout << endl;
    }
}

Output

Enter rows and column for first matrix: 3
2
Enter rows and column for second matrix: 3
2
Error! column of first matrix not equal to row of second.

Enter rows and column for first matrix: 2
3
Enter rows and column for second matrix: 3
2

Enter elements of matrix 1:
Enter elements a11: 3
Enter elements a12: -2
Enter elements a13: 5
Enter elements a21: 3
Enter elements a22: 0
Enter elements a23: 4

Enter elements of matrix 2:
Enter elements b11: 2
Enter elements b12: 3
Enter elements b21: -9
Enter elements b22: 0
Enter elements b31: 0
Enter elements b32: 4

Output Matrix:
24 29

6  25
موافقین ۰ مخالفین ۰ ۹۵/۰۷/۱۶
مدیرکل

نظرات (۰)

هیچ نظری هنوز ثبت نشده است

ارسال نظر

ارسال نظر آزاد است، اما اگر قبلا در بیان ثبت نام کرده اید می توانید ابتدا وارد شوید.
شما میتوانید از این تگهای html استفاده کنید:
<b> یا <strong>، <em> یا <i>، <u>، <strike> یا <s>، <sup>، <sub>، <blockquote>، <code>، <pre>، <hr>، <br>، <p>، <a href="" title="">، <span style="">، <div align="">
تجدید کد امنیتی