גוקר בקרוקר
New member
יש לי שאלה בJAVA
נגדיר: אלכסון ראשי של מערך דו-ממדי b ריבועי בגודל nn מכיל את האיברים b[0,0],b[1,1],...,b[n-1,n-1]). הוסיפו למחלקה Matrix שיטה בשם square. השיטה תבדוק האם קיים מערך דו-ממדי ריבועי חלקי בפינה הימנית התחתונה של המערך המאוחסן במחלקה Matrix אשר מכיל 1 -ים באלכסונו הראשי והיתר אפסים. אם קיים - השיטה תחזיר את מספר השורות/עמודות של מערך ריבועי חלקי זה; אם לא קיים - השיטה תחזיר 0. חתימת השיטה תהיה: public int square() כאשר Method Summary Matrix add(Matrix other) Returns the matrix resulting from adding this matrix with another. double getElement(int row, int column) int getNumberOfColumns() int getNumberOfRows() Matrix multiply(Matrix other) Returns the matrix resulting from multiplying this matrix with another. void multiplyByScalar(double c) multiplies the matrix by a given scalar void setElement(int row, int column, double value) sets the value of a given index to a given value java.lang.String toString() הבעיה שלי היא שאני לא יודע איך להתחיל לכתוב את השיטה SQUARE אשמח אם תוכלו להדריך אותי תודה מראש
נגדיר: אלכסון ראשי של מערך דו-ממדי b ריבועי בגודל nn מכיל את האיברים b[0,0],b[1,1],...,b[n-1,n-1]). הוסיפו למחלקה Matrix שיטה בשם square. השיטה תבדוק האם קיים מערך דו-ממדי ריבועי חלקי בפינה הימנית התחתונה של המערך המאוחסן במחלקה Matrix אשר מכיל 1 -ים באלכסונו הראשי והיתר אפסים. אם קיים - השיטה תחזיר את מספר השורות/עמודות של מערך ריבועי חלקי זה; אם לא קיים - השיטה תחזיר 0. חתימת השיטה תהיה: public int square() כאשר Method Summary Matrix add(Matrix other) Returns the matrix resulting from adding this matrix with another. double getElement(int row, int column) int getNumberOfColumns() int getNumberOfRows() Matrix multiply(Matrix other) Returns the matrix resulting from multiplying this matrix with another. void multiplyByScalar(double c) multiplies the matrix by a given scalar void setElement(int row, int column, double value) sets the value of a given index to a given value java.lang.String toString() הבעיה שלי היא שאני לא יודע איך להתחיל לכתוב את השיטה SQUARE אשמח אם תוכלו להדריך אותי תודה מראש