الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مساهدة في حل سؤال

بدأه الخيال55 في 25 ديسمبر 2010 · 3 رد · 629 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

Write function to add and multiply two matrices. The header of the

functions is as follow:

void addMatrix( int a[][COULMN_SIZE], int b[][COULMN_SIZE],

int c[][COULMN_SIZE], int rowSize )

c matrix will hold the result of adding

void multiplyMatrix( int a[][COULMN_SIZE],

intb [][COULMN_SIZE],

int c[][COULMN_SIZE], int rowSize )

c matrix will hold the result of multiplying

هدا سؤال حليت بس مابعرف اجمع الرحاء مساعدتي

الحل بالمرفق

#include <iostream>

using namespace std;

const int COLUMN_SIZE = 5;

/** The method for multiplying two matrices */

void multiplyMatrix(int a[] [COLUMN_SIZE], int b[] [COLUMN_SIZE], int result[] [COLUMN_SIZE], int rowSize)

{

for (int i = 0; i < COLUMN_SIZE; i++)

for (int j = 0; j < COLUMN_SIZE; j++)

for (int k = 0; k < COLUMN_SIZE; k++)

result [j] += a [k] * b[k] [j];

}

/** Print result */

void printResult(int m1[] [COLUMN_SIZE], int m2[] [COLUMN_SIZE], int m3[] [COLUMN_SIZE], char op, int rowSize)

{

for (int i = 0; i < rowSize; i++)

{

for (int j = 0; j < COLUMN_SIZE; j++)

cout << " " << m1 [j];

if (i == COLUMN_SIZE / 2)

cout << " " << op << " ";

else

cout << " ";

for (int j = 0; j < COLUMN_SIZE; j++)

cout << " " << m2 [j];

if (i == COLUMN_SIZE / 2)

cout << " = ";

else

cout << " ";

for (int j = 0; j < COLUMN_SIZE; j++)

cout << " " << m3 [j];

cout << endl;

}

}

int main()

{

// Create two matrices as two dimensional arrays

int matrix1[5] [5];

int matrix2[5] [5];

int result[5] [5];

// Assign random values to matrix1 and matrix2

for (int i = 0; i < 5; i++)

for (int j = 0; j < 5; j++)

{

matrix1 [j] = rand();

matrix2 [j] = rand();

}

multiplyMatrix(matrix1, matrix2, result, 5);

cout << "The multiplication of the matrices is " << endl;

printResult(matrix1, matrix2, result, '*', 5);

system ("pause");

}

444.cpp

1 −1
#2

مافي حذا يساعد

1 −1
#3

هي كود الجمع بس منا عارف استدعي

void addMatrix( int a[2][2], int b[2][2],int c[2][2], int RowColomSize )

{

int x = RowColomSize ;// ÇÓåá Ýí ÇáÊÚÇãá

for (int i=0 ; i<x ; i++)

{

for (int j=0 ; j<x ; j++ )

c[j] = a[j] + b[j] ;

}

cout << " add of arrays is \n " ;

for(int i=0;i<2;i++)

{

for(int z=0 ; z<2 ; z++)

cout << c[z] << " ";

cout << "\n" ;

}

}

#4

السلام عليكم ورحمة الله وبركاته

اخي هدا ماقدرت استطيع مساعدتك

ادخل عناصر مصفوفتين وانت تستطيع التحكم في ابعاد المصفوفتين على شرط ان يكونو من نفس الرتيه وبالتوفيق ان شاء الله

matrix.cpp

IBRAHIM ALZAIDI

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…