简体   繁体   中英

constructing shapes in a matrix - java

I'm having some troubles starting a programming assignment. i have an matrix, size NXN with all zeros.

i need to create and check all of the "shapes" that can be drawn on this matrix. a shape is a "line" of ones starting in the N,0 point - the line can first go either up or right ( if Mat[5][5] = 1, than the next 1 will be in [5][6] or in [4][5] ). from a cretin point called the decision point the line can only go right or down until it reaches the N row again and the line ends.

i need to go over ALL of the options for a line in a given matrix and perform some calculations (which is the easy part) and return the maximum from all of them. my problem is that i don't know how i can receive all of the options. It should probably be some kind of recursion which at each point of the process gives me a matrix built from either picking down/up/right but im really stuck with it.

does anyone have any ideas ?

[如您所愿],请使用Backtracking算法

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM