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

Matrix Multiplication Code

مغلق
بدأه AHMED_NASHA2Y في 12 سبتمبر 2005 · 1 رد · 659 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

salam 3alekom

i want to make a code to multiply two matrices

i think the algorithm is right(but if it was wrong tell me plz)

but the problem that when i want to pass a matrix to apublic function that i made (not static ) it gives me a n error can anyone tell me why that ?

this is the code :

public class Class1

{

public static void main ()

{

int[,] ahmed={ {1,2}, {1,5}};

//the first matrix

int[,] nageeb={ {1,5}, {5,9}};

//the second one

mohamed( ahmed, nageeb);

//here the compiler gives me an error

}

public void mohamed(int[,] a , int[,] B)

{

int[,] c;

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

{

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

{

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

{

c[l,k]+=(a[l,i])*(b[i,k]);

}

}

System.Console.WriteLine(c[l,k]);

}

}

}

شكرا

}

#2

بسم الله الرحمن الرحيم

أخي جرب هذا الكود وأعطي رأيك :

public class Class1
{

public static void main ()
{
Class1 C=new Class1();
int[,] ahmed={ {1,2}, {1,5}};
//the first matrix 
int[,] nageeb={ {1,5}, {5,9}};
//the second one 
C.mohamed( ahmed, nageeb); 
//here the compiler gives me an error 

}



public void mohamed(int[,] a , int[,] )
{
int[,] c;
for(int k=0;k<2;k++)
{
for(int l=0;l<2;l++)
{
for(int i=0;i<2;i++)
{
c[l,k]+=(a[l,i])*(b[i,k]);

}
}
System.Console.WriteLine(c[l,k]);
}

}

}

هذا الموضوع مغلق.

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