# Knot pair Development Three ~ ~

Source: Internet
Author: User

First, title and requirements:

Title: Returns the and of the largest sub-array in an integer array.

Requirements (new addition): ① requires that the program must be able to handle 1000 elements; ② each element is of type Int32.

Second, design ideas

At the beginning of the old wet said when Baidu half-day Leng not understand ... So after the sister, they explained a half-day to understand. This exercise is still done on the basis of a previous one-dimensional array, the first problem is to ask the program to process 1000 data and require that the element is int32 type, so there will be large number overflow problem, our idea is to find it and make a warning

Third, the source program

` 1//Pair personnel Gai Xianggeng Caomeina 2 3 #include "stdafx.h" 4 #include "stdio.h" 5 #include "stdlib.h" 6 #include "time.h" 7 #define N 1000 8 int Compare (int arry[],int length) 9 {Ten int max[n],max1;11 for (int j=0;j<length;j++)-{int.             SUM=0;14 max1=-987654321;15 for (int i=j;i<length;i++), {sum=sum+arry[i];18 if (sum<0)//Determine if it overflows ("value overflow!") \ n "), return 0;22}23 else if (SUM&GT;=MAX1)     x1=sum;26}27}28 max[j]=max1;29 printf ("contains all sub-arrays with the number of%d in the array and the maximum value is:%d\n", J+1,max[j]); 30 }31 int fmax=max[0];32 for (int i=0;i<length;i++) (Max[i]>fmax) + FMA     x=max[i];36}37 printf ("The maximum value of all sub-arrays is:%d\n", Fmax); return 0;39}40 int main (int argc, char* argv[]) 41 {42 int arry[n];43 int length;44 srand (Time (NULL)); printf ("Please enter the number of integers to compare:"); scanf ("%d", &length); 49 for (int i=0;i<length;i++) {50 Arry[i]=rand () +100000000;51}53 printf ("Randomly generated array is: \ n"); rintf ("%d\t", Arry[i]);}59 compare (Arry,length); return 0;61}`

Four

Five, experience

This is the procedure or sister na ... So above the content is Na sister handedly. I am responsible for the study, and every time is NA sister finished the program after I see a few times. At the very least, you should be able to understand. In the future should study hard, improve the basic ability of C language, want to learn from the great God. Don't mess around with other useless things ... That's it.

Vi. Work Photos

Knot pair Development Three ~ ~

Related Keywords:

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.