Software Engineering class exercises--pair development

Source: Internet
Author: User

First, the topic requirements

Title: Returns the number of the largest sub-arrays in a two-dimensional integer array. Requirements: Enter a two-dimensional shape array with positive and negative numbers in the array. A two-dimensional array is connected to the end of the line, like a belt. One or more consecutive integers in an array make up a sub-array, each of which has a and. The maximum value for the and of all sub-arrays. Requires a time complexity of O (n). Second, the design of the idea of the topic is the design of the last array of ideas, the two-dimensional array of each row as an array, and then make the extension, the program is still using a two-dimensional array of that, on this basis to make a slight change on the line three, the source code
1 //Program Developer: Caomeina Gai Xianggeng2 //Development time: 2015/3/313 4#include"stdafx.h"5#include"fstream.h"6#include"iostream.h"7#include"stdio.h"8 #defineN 509 #defineM 50Ten  One voidReadarry (intArry[][n],int&line,int&row)//reading a two-dimensional array in a TXT file A { -Ifstream infile ("a.txt"); -     if(!infile) thecout<<"Read failed! "<<Endl; -     Else -     { -Infile>>line>>Row; +          for(intI=0; i<line;i++) -         { +              for(intj=0; j<row;j++) A             { atInfile>>Arry[i][j]; -             } -         } -     } - } -  in intMaxarry (intArry[][n],intLineintRow//find the maximum value of elements in a two-dimensional array in a neutron matrix - { to     intMax[n]; +printf"after the above array has been deformed: \ n"); -      for(intL=0; l<line;l++)                 the     { *         intmax1=- +; $           for(intj=0;j< (row+1)/2; j + +)Panax Notoginseng         { -             intsum=0;  the              for(inti=j;i< (row+1)/2; i++) +            { Asum=sum+Arry[l][i]; the                 if(sum>=max1) +                 { -max1=sum; $                 } $            } -                          -          } themax[l]=max1; -              Wuyiprintf"The maximum value of all sub-arrays in the set of%d is:%d\n", L +1, max1); the     } -     intfmax=max[0]; Wu      for(intq=0; q<line;q++) -     { About         if(max[q]>Fmax) $fmax=Max[q]; -     } -printf"so the maximum value of the number of elements in the second two-digit neutron array is:%d\n", Fmax); -          A         return 0; + } the  - voidReacharry (intArry[][n],intLineintRow//make up a new array $ { the     intSumarry[m][n]; the     intSumline,sumrow; the     intZ; the      for(intR=0; r<row;r++) -     { inz=0; the          for(intI=0; i<line;i++) the         { About              for(intQ=line;q>0; q--) the             { the                 intsum=0; the                  for(intj=i;j<=line-q+i;j++) +                 { -sum=sum+Arry[j][r]; the                 }            Bayisumarry[z][r]=sum; thez++;  the             } -         } -     } thesumline=z-1; thesumrow=R;  theMaxarry (Sumarry,sumline,sumrow);//give Maxsrry () the resulting new array and find the final result the  - } the  the intExpandintArry[][n],int&line,int&row)//extend the two-dimensional array the {94     intArry1[n][n]; the      for(intI=0; i<line;i++) the     { the          for(intj=0; j<row;j++)98         { Aboutarry1[i][j]=Arry[i][j]; -         }101     }102     intnum=0;103      for(i=0; i<line;i++)104     { the          for(intq=row;q<2*row-1; q++)106         {107arry[i][q]=Arry[i][num];108num++;109         } the     }111Reacharry (Arry1,line,2*row-1); the 113     return 0; the  the } the 117 118 119 voidShowintArry[][n],intLineintRow//Display Array - {121printf"The array read from the "a.txt" file is: \ n");122      for(intI=0; i<line;i++)123     {124          for(intj=0; j<row;j++) the         {126printf"\t%d\t", Arry[i][j]);127         } -printf"\ n");129     } the }131  the 133 134 135 intMainintargcChar*argv[])136 {137     intArry[m][n];138     intLine,row;//row, column139 Readarry (arry,line,row); $ Show (Arry,line,row);141 expand (arry,line,row);142     143    return 0;144}

Four

Perhaps because I did not speak of the expansion of the array output, so the reader may not be able to see the design ideas, in fact, design ideas in my several blogs have mentioned that the program design ideas are the same

Five, experience

This knot has the shortest development time, because it is in the last two-dimensional array to do the expansion, so the idea is very clear, so the completion of the teacher said to want us to relax a little, so there will be a period of time will not be in and my small partner pair programming, summarize this several times the knot pair development idea, My small partner is still very strong, but is relatively deprecating, not too trust their ability, sometimes think of things he is faster than me, thinking more active than me, I hope Guegnes classmates work hard, not too early to cover their own labels.

Pair development is to 2 people to their own ideas, enthusiasm to each other, the beginning of the teacher called us to practice the purpose of this is too formal, but a few times down I think we will have their own harvest, can learn something from each other, I think we will be in this period of time slowly grow up.

Software Engineering class exercises--pair development

Related Article

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.