dividing matrix into four sub-blocksDoes a finally block always get executed in Java?Fastest way to determine if an integer's square root is an integerHow do I read / convert an InputStream into a String in Java?What is the difference between a static and a non-static initialization code blockHow to reference sub-matrices within a matrixHow do I convert a String to an int in Java?Dealing with “Xerces hell” in Java/Maven?Find the largest-sum sub-matrixdivide matrix to blocks with parallel diagonal linesJava 8 Distinct by property

How can saying a song's name be a copyright violation?

How can I deal with my CEO asking me to hire someone with a higher salary than me, a co-founder?

Why is the sentence "Das ist eine Nase" correct?

Does int main() need a declaration on C++?

How could indestructible materials be used in power generation?

How badly should I try to prevent a user from XSSing themselves?

How do conventional missiles fly?

Why was the shrink from 8″ made only to 5.25″ and not smaller (4″ or less)

Why do I get negative height?

One verb to replace 'be a member of' a club

Is there a hemisphere-neutral way of specifying a season?

Send out email when Apex Queueable fails and test it

Venezuelan girlfriend wants to travel the USA to be with me. What is the process?

How to compactly explain secondary and tertiary characters without resorting to stereotypes?

Why were 5.25" floppy drives cheaper than 8"?

What historical events would have to change in order to make 19th century "steampunk" technology possible?

how do we prove that a sum of two periods is still a period?

Ambiguity in the definition of entropy

How to show a landlord what we have in savings?

Mathematica command that allows it to read my intentions

What reasons are there for a Capitalist to oppose a 100% inheritance tax?

My ex-girlfriend uses my Apple ID to log in to her iPad. Do I have to give her my Apple ID password to reset it?

Can a virus destroy the BIOS of a modern computer?

GFCI outlets - can they be repaired? Are they really needed at the end of a circuit?



dividing matrix into four sub-blocks


Does a finally block always get executed in Java?Fastest way to determine if an integer's square root is an integerHow do I read / convert an InputStream into a String in Java?What is the difference between a static and a non-static initialization code blockHow to reference sub-matrices within a matrixHow do I convert a String to an int in Java?Dealing with “Xerces hell” in Java/Maven?Find the largest-sum sub-matrixdivide matrix to blocks with parallel diagonal linesJava 8 Distinct by property













0















i want devide matrix into four sub-blocks equally by vertically and horizontallty in java (Here, we suppose that m and nare even numbers) .



for example we have matrix:



1 2 3 4 5 6 
7 8 9 1 2 8
1 2 3 4 5 6
4 5 6 7 8 9
1 4 7 2 5 8
3 6 9 7 2 5


I want to display the last block that is:



7 8 9
2 5 8
7 2 5


how i can resolve this problem in java.










share|improve this question



















  • 3





    Iterate over the right part of the matrix. What did you try so far? Please show us your efforts

    – MWB
    Mar 21 at 17:28












  • how i can do this. can you help me?

    – rouin
    Mar 21 at 17:31











  • All you need is 4 for loops. Begin with the top left corner.

    – Arnaud Denoyelle
    Mar 21 at 17:33












  • I'm thinking a nested for loop where i and j start at n/2 or m/2. You should try to implement this yourself and come back with the problems you face and ask a more specific question.

    – Patrick
    Mar 21 at 17:33











  • Help us helping you by at least throwing in some code you did yourself. We will not code this for you.

    – NaeiKinDus
    Mar 21 at 17:33















0















i want devide matrix into four sub-blocks equally by vertically and horizontallty in java (Here, we suppose that m and nare even numbers) .



for example we have matrix:



1 2 3 4 5 6 
7 8 9 1 2 8
1 2 3 4 5 6
4 5 6 7 8 9
1 4 7 2 5 8
3 6 9 7 2 5


I want to display the last block that is:



7 8 9
2 5 8
7 2 5


how i can resolve this problem in java.










share|improve this question



















  • 3





    Iterate over the right part of the matrix. What did you try so far? Please show us your efforts

    – MWB
    Mar 21 at 17:28












  • how i can do this. can you help me?

    – rouin
    Mar 21 at 17:31











  • All you need is 4 for loops. Begin with the top left corner.

    – Arnaud Denoyelle
    Mar 21 at 17:33












  • I'm thinking a nested for loop where i and j start at n/2 or m/2. You should try to implement this yourself and come back with the problems you face and ask a more specific question.

    – Patrick
    Mar 21 at 17:33











  • Help us helping you by at least throwing in some code you did yourself. We will not code this for you.

    – NaeiKinDus
    Mar 21 at 17:33













0












0








0


1






i want devide matrix into four sub-blocks equally by vertically and horizontallty in java (Here, we suppose that m and nare even numbers) .



for example we have matrix:



1 2 3 4 5 6 
7 8 9 1 2 8
1 2 3 4 5 6
4 5 6 7 8 9
1 4 7 2 5 8
3 6 9 7 2 5


I want to display the last block that is:



7 8 9
2 5 8
7 2 5


how i can resolve this problem in java.










share|improve this question
















i want devide matrix into four sub-blocks equally by vertically and horizontallty in java (Here, we suppose that m and nare even numbers) .



for example we have matrix:



1 2 3 4 5 6 
7 8 9 1 2 8
1 2 3 4 5 6
4 5 6 7 8 9
1 4 7 2 5 8
3 6 9 7 2 5


I want to display the last block that is:



7 8 9
2 5 8
7 2 5


how i can resolve this problem in java.







java






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 21 at 20:33









Sterling Archer

16.1k126191




16.1k126191










asked Mar 21 at 17:23









rouinrouin

13




13







  • 3





    Iterate over the right part of the matrix. What did you try so far? Please show us your efforts

    – MWB
    Mar 21 at 17:28












  • how i can do this. can you help me?

    – rouin
    Mar 21 at 17:31











  • All you need is 4 for loops. Begin with the top left corner.

    – Arnaud Denoyelle
    Mar 21 at 17:33












  • I'm thinking a nested for loop where i and j start at n/2 or m/2. You should try to implement this yourself and come back with the problems you face and ask a more specific question.

    – Patrick
    Mar 21 at 17:33











  • Help us helping you by at least throwing in some code you did yourself. We will not code this for you.

    – NaeiKinDus
    Mar 21 at 17:33












  • 3





    Iterate over the right part of the matrix. What did you try so far? Please show us your efforts

    – MWB
    Mar 21 at 17:28












  • how i can do this. can you help me?

    – rouin
    Mar 21 at 17:31











  • All you need is 4 for loops. Begin with the top left corner.

    – Arnaud Denoyelle
    Mar 21 at 17:33












  • I'm thinking a nested for loop where i and j start at n/2 or m/2. You should try to implement this yourself and come back with the problems you face and ask a more specific question.

    – Patrick
    Mar 21 at 17:33











  • Help us helping you by at least throwing in some code you did yourself. We will not code this for you.

    – NaeiKinDus
    Mar 21 at 17:33







3




3





Iterate over the right part of the matrix. What did you try so far? Please show us your efforts

– MWB
Mar 21 at 17:28






Iterate over the right part of the matrix. What did you try so far? Please show us your efforts

– MWB
Mar 21 at 17:28














how i can do this. can you help me?

– rouin
Mar 21 at 17:31





how i can do this. can you help me?

– rouin
Mar 21 at 17:31













All you need is 4 for loops. Begin with the top left corner.

– Arnaud Denoyelle
Mar 21 at 17:33






All you need is 4 for loops. Begin with the top left corner.

– Arnaud Denoyelle
Mar 21 at 17:33














I'm thinking a nested for loop where i and j start at n/2 or m/2. You should try to implement this yourself and come back with the problems you face and ask a more specific question.

– Patrick
Mar 21 at 17:33





I'm thinking a nested for loop where i and j start at n/2 or m/2. You should try to implement this yourself and come back with the problems you face and ask a more specific question.

– Patrick
Mar 21 at 17:33













Help us helping you by at least throwing in some code you did yourself. We will not code this for you.

– NaeiKinDus
Mar 21 at 17:33





Help us helping you by at least throwing in some code you did yourself. We will not code this for you.

– NaeiKinDus
Mar 21 at 17:33












1 Answer
1






active

oldest

votes


















0














Iterate over the lower-right part of the matrix. Here is an example for a square matrix. I am sure you will be able to make it more generic for non-square quadrants or to get other quadrants than the lower-right one.



public int[][] getQuadrantOfSquareMatrix(int[][] matrix) 
int newDimension = matrix.length / 2;
int[][] toReturn = new int[newDimension][newDimension];
for (int i = 0; i < newDimension; i++)
for (int j = 0; j < newDimension; j++)
toReturn[i][j] = matrix[i + newDimension][j + newDimension];


return toReturn;






share|improve this answer























  • You can’t assume that the matrix is square, only that both dimensions are even.

    – Joakim Danielson
    Mar 21 at 20:38











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55285990%2fdividing-matrix-into-four-sub-blocks%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Iterate over the lower-right part of the matrix. Here is an example for a square matrix. I am sure you will be able to make it more generic for non-square quadrants or to get other quadrants than the lower-right one.



public int[][] getQuadrantOfSquareMatrix(int[][] matrix) 
int newDimension = matrix.length / 2;
int[][] toReturn = new int[newDimension][newDimension];
for (int i = 0; i < newDimension; i++)
for (int j = 0; j < newDimension; j++)
toReturn[i][j] = matrix[i + newDimension][j + newDimension];


return toReturn;






share|improve this answer























  • You can’t assume that the matrix is square, only that both dimensions are even.

    – Joakim Danielson
    Mar 21 at 20:38















0














Iterate over the lower-right part of the matrix. Here is an example for a square matrix. I am sure you will be able to make it more generic for non-square quadrants or to get other quadrants than the lower-right one.



public int[][] getQuadrantOfSquareMatrix(int[][] matrix) 
int newDimension = matrix.length / 2;
int[][] toReturn = new int[newDimension][newDimension];
for (int i = 0; i < newDimension; i++)
for (int j = 0; j < newDimension; j++)
toReturn[i][j] = matrix[i + newDimension][j + newDimension];


return toReturn;






share|improve this answer























  • You can’t assume that the matrix is square, only that both dimensions are even.

    – Joakim Danielson
    Mar 21 at 20:38













0












0








0







Iterate over the lower-right part of the matrix. Here is an example for a square matrix. I am sure you will be able to make it more generic for non-square quadrants or to get other quadrants than the lower-right one.



public int[][] getQuadrantOfSquareMatrix(int[][] matrix) 
int newDimension = matrix.length / 2;
int[][] toReturn = new int[newDimension][newDimension];
for (int i = 0; i < newDimension; i++)
for (int j = 0; j < newDimension; j++)
toReturn[i][j] = matrix[i + newDimension][j + newDimension];


return toReturn;






share|improve this answer













Iterate over the lower-right part of the matrix. Here is an example for a square matrix. I am sure you will be able to make it more generic for non-square quadrants or to get other quadrants than the lower-right one.



public int[][] getQuadrantOfSquareMatrix(int[][] matrix) 
int newDimension = matrix.length / 2;
int[][] toReturn = new int[newDimension][newDimension];
for (int i = 0; i < newDimension; i++)
for (int j = 0; j < newDimension; j++)
toReturn[i][j] = matrix[i + newDimension][j + newDimension];


return toReturn;







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 21 at 17:36









MWBMWB

8761819




8761819












  • You can’t assume that the matrix is square, only that both dimensions are even.

    – Joakim Danielson
    Mar 21 at 20:38

















  • You can’t assume that the matrix is square, only that both dimensions are even.

    – Joakim Danielson
    Mar 21 at 20:38
















You can’t assume that the matrix is square, only that both dimensions are even.

– Joakim Danielson
Mar 21 at 20:38





You can’t assume that the matrix is square, only that both dimensions are even.

– Joakim Danielson
Mar 21 at 20:38



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55285990%2fdividing-matrix-into-four-sub-blocks%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript