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

مرحبا ممكن مساعده...

مغلق
بدأه IT girl في 8 مايو 2004 · 11 رد · 1,129 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

Task

You are going to write a Java Program which does the following operations.

1. Read the size of a matrix n from the keyboard.

2. Create three integer matrices A[n][n], B[n][n] and C[n][n].

3. Use a method to fill up the two arrays A and B by positive and/or negative integer random numbers between 0 and 6 (Hint: to obtain negative numbers, just select randomly any positive integer number and convert it to negative).

4. Use a method to multiply the elements of the two matrices A and B and store the result in matrix C as shown in the example below.

5. Use a method to print the elements of matrix A in a two digit decimal format.

6. Use the same print method to print matrices B and C to the screen in the format shown in the example below.

The Equation and Pseudo Codes for Matrix Multiplication are shown below.

Cij =  Aik * Bkj (for k = 1 to k = n)

For i = 1 to n

For j = 1 to n do

Cij = 0

For k = 1 to n

Cij = Cij + Aik * Bkj

Running Example of Matrix Multiplication:

What is the size of your Matrix (2-10)? 4

Matrix A:

-2 5 0 1

4 1 6 -3

1 2 -4 5

-6 0 2 1

Matrix B:

5 -6 1 -4

0 3 -4 3

3 1 2 0

4 -5 1 3

Matrix C = A*B:

-6 -2 -21 10

26 0 9 -22

13 -29 -10 17

-20 -39 -1 27

#2

لا اعرف ما ساقول .....

سوف التزم بالسكوت فقط ....

يا اختي الله يسامحك طيب شو بدي احكي كل يوم لازم ياتي موضوع مثل موضوعك المخالف 100% من كل النواحي

يرجى منك قراءة : قواعد المشاركة

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

#3

import java.io.*;

public class multmatrix{

public static void main(String [] args )

throws IOException

{

int n ;

BufferedReader din = new BufferedReader( new InputStreamReader(System.in));

System.out.print("n : ");

n = Integer.parseInt(din.readLine());

int [][] a = new double [n][n] ;

int [][] f = new double [n][n] ;

System.out.println("Matrix A :");

for( int i = 0;i<f.length;i++)

{

for( int j = 0 ;j< f[0].length;j++)

{

System.out.print("f["+i+"]["+j+"]: ");

int l = Integer.parseInt(din.readLine());

f[j] = l ;

}

}

System.out.println("Matrix B :");

for( int i = 0;i<a.length;i++)

{

for( int j = 0 ;j< a[0].length;j++)

{

System.out.print("a["+i+"]["+j+"]: ");

int o = Integer.parseInt(din.readLine());

a[j] = o ;

}

}

System.out.println("A*B :\n");

int t = 0 ;

int [][] c = new int [f.length][a[0].length];

for( int i = 0 ;i<f.length;i++)

{

for( int k = 0 ;k<a[0].length;k++)

{

c[k] = 0 ;

for( int j = 0 ;j<f[0].length;j++)

{

c[k] +=f[j]*a[j][k] ;

}

System.out.print(c[k]);

System.out.print(" ");

}

t = t+1 ;

if( t == 4);

System.out.println();

}

}

}

لست متواجد بشكل يومي

#4

السلام عليكم

اختي لو سمحتي ممكن توضحين سؤالج؟؟

والكود صراحه مافهمته

#5

import java.io

.*;
public class multimatrix{
public static void main(String [] args )
throws IOException
{
 int  n;
   BufferedReader din = new BufferedReader( new InputStreamReader(System.in));
 System.out.print("Anzahl der  Zeilen der ersten Matrix: ");
     n  = Integer.parseInt(din.readLine());

int   [][] a = new int [n][n]; //Matrix  A
int   [][] f = new int [n][n];//Matrix  B

// Read The Matrix A from the Keyboard
System.out.println("Matrix A :");
for( int  i = 0;i<f.length;i++)
{
     for( int j = 0;j< f[0].length;j++)
        {
            
 System.out.print("f["+i+"]["+j+"]: ");
    int  l  = Integer.parseInt(din.readLine());
  f[j] = l;

 }
}
// Read The Matrix B from the Keyboard

System.out.println("Matrix B :");
for( int  i = 0;i<a.length;i++)
{
     for( int j = 0;j< a[0].length;j++)
        {
            
 System.out.print("a["+i+"]["+j+"]: ");
    int  o  = Integer.parseInt(din.readLine());
  a[j] = o;

 }
}
System.out.println("Multiplikation der beiden Matrizen :\n");
int  t = 0;
int [][] c =  new int [f.length][a[0].length]; //Matrix C = A*B
// Output Matrix C
for( int i = 0;i<f.length;i++)
    {
         for( int k  = 0;k<a[0].length;k++) 
       {
            c[k] = 0;
           for( int j = 0;j<f[0].length;j++)
             {
                  c[k] +=f[j]*a[j][k];
              
              } 
 System.out.print(c[k]);
  System.out.print(" ");
}
       t = t+1;
    if( t == 4);
                System.out.println();
}
}
}

لست متواجد بشكل يومي

#6

يا شباب انت شو تسون .....

مو قلنا لكم نحن لا نحل الوظائف .... و لا صعبة هذي تنفهم

يرجى قراءة شروط و قواعد المشاركة قبل التشاطر بالاجابة....

يعني مفتكرين انكم ساعدتم..... لقد سببتم الضرر شو هل الوظيفة اللي ياتي حلها جاهز دون ان تتعلم و تتعذب حتى ينجح معها الكود

نحن نساعد فقط

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

#7

أولا اقدم الشكر للاخوان الي ساعدوني في الكود ...

ثانيا ..

أخوي ..رامي ..

تعقد ليش انا كطالبه ادرس جافا ممكن اني اطلب حل لوظيفه من منتدى أو من أي مكان .. ؟؟؟صدقني أنا آخذ الكورس صارلي اكثر من شهرين و ما فكرت اني آخذ كود من المنتدى .. بس انا في الوقت الحالي اعاني من ازدحام الوظائف في كل المواد .. يعني انا كان عندي غير هذي الوظيفه ست وظائف أحاول اني احلها و حليت بعض منها بدون مساعده .. فلا تكون ظالم و تضغط عليه اكثر ما انا مضغوطه .. و شكرا ..

#8

اخوي رامي شكرا لحرصك المفيد لنا

لكن بما انه الكود انكتب ارجو انك تسمحلنا مناقشته حتى نكون فاهمين

[cod BufferedReader din = new BufferedReader( new InputStreamReader(System.in));;

مافهمت هذا السطر؟؟؟

#9

اخوي رامي شكرا لحرصك المفيد لنا

لكن بما انه الكود انكتب ارجو انك تسمحلنا مناقشته حتى نكون فاهمين

 BufferedReader din = new BufferedReader( new InputStreamReader(System.in));
#10

خلاص اذا انت "مضغوطة " كثير مثل ما تقولين معليش هل المرة بس ارجو عدم تكرار هذه الاشياء ... في المستقبل..

و الحل هو تنظيم الوقت

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

#11

الأخ طالب برمجة

السطر

BufferedReader din = new BufferedReader( new InputStreamReader(System.in));

يستقبل المدخلات من المستخدم. ويعادل تقريبا في لغة C++:

cin>> x>>endl;

فكر بطريقة أخرى

#12

مشكورين على توضيح الكود ...مع اني أضم صوتي للأخ رامي ..لأني هذه الوظيفة عندي بعد ..و انا بعدني ما جربت أحلها بس ..و فجأة حصلت الكود جدامي ...و الانسان ما يتعلم الا اذا أخطأ و جرب يشوف و ين الخطأ ..و يصححه ...و مشكورين مرة ثانية

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

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