Unicom sub-array maximum value design 03

Source: Internet
Author: User

so depressed, I first put the teacher's questions to write out ;

Returns the and of the largest interconnected subarray in a two-dimensional integer array.

Requirements:

Enter a two-dimensional shaping array with positive numbers in the array and a negative number.

The maximum value for the and of all sub-arrays. The following is an example diagram:

Recently has been completely caught in the cycle of programming, I did not find their own direction, not much to say, directly on the problem: in the sub-array problem I think the basic is a sub-array of deformation, there should be no special changes, up to the difficulty up, but the basic ideas will not change, today I found the wrong, maybe I was wrong.

My idea: Look at the code on the Internet to find the inspiration: because I think the teacher in class to talk about the figure of the method some trouble, so I would like to use a one-dimensional array of methods AC. Start is to find the two-dimensional array of each one-dimensional array of the maximum sub-array of the starting point, and then see if it can be connected to the direct add, not even to find a way to link, and finally add a special situation, just fine. However, to really reconsider this vague to find a cost of the least path, I am dazed, this still need to use the figure to solve it. First put out the code, after the problem must be perfected, if there is good advice please @ me, thank you.

#include <iostream>using namespace std;void max_place (int row,int &max,int fl[],int &start,int &end);    int main () {int a[100][100];int fl[100];int hang=0,lie=0;int start_k[100],end_k[100];    Defines a two-dimensional array where each start stop position int large[100];int max=0;int start=0,end=0; Positional parameter cout<< "Please enter array number of rows:" <<endl;cin>>hang>>lie; int I=0,j=0;for (i=0;i

  

Recent improvements, Thank you

Unicom sub-array maximum value design 03

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.