Work requirements | https://edu.cnblogs.com/campus/jssf/infor_computation17-31/homework/10454 |
---|---|
My aim in this course is | Improve their ability related |
This job helped me in terms of what specific goals | Contacts and acquire new software features |
Text of the job | https://www.cnblogs.com/wyc1/p/12459804.html |
gitee link | https://gitee.com/wu_yu_chen1/learngit/blob/master/array.cpp |
Text of the job
program
#include<iostream>
#include<cstdlib>
using namespace std;
int getmax(int array[],int length)
{
int sum = 0;
int max = 0;
int startIndex = 0; //记录子数组的起始位置
int endIndex = 0; //记录子数组的终止位置
int newStartIndex = 0;
for (int i = 0; i < length; i++) //遍历整个目标数组
{
if (max < 0)
{
max = array[i];
newStartIndex = i;
}
else
{
max += array[i];
}
if (sum < max) //如果此时 sum < temp;
{
sum = max;
startIndex = newStartIndex;
endIndex = i;
}
}
return max;
}
int getstartIndex(int array[],int length)
{
int sum = 0;
int max = 0;
int startIndex = 0;
int endIndex = 0;
int newStartIndex = 0;
for (int i = 0; i < length; i++)
{
if (max < 0)
{
max = array[i];
newStartIndex = i;
}
else
{
max += array[i];
}
if (sum < max)
{
sum = max;
startIndex = newStartIndex;
endIndex = i;
}
}
return startIndex;
}
int getendIndex(int array[],int length)
{
int sum = 0;
int max = 0;
int startIndex = 0;
int endIndex = 0;
int newStartIndex = 0;
for (int i = 0; i < length; i++)
{
if (max < 0)
{
max = array[i];
newStartIndex = i;
}
else
{
max += array[i];
}
if (sum < max)
{
sum = max;
startIndex = newStartIndex;
endIndex = i;
}
}
return endIndex;
}
int main()
{
int length,i=0;
cout<<"请输入个数:";
cin>>length;
cout<<"请输入数组:";
int array[1000]={0};
for(i=0;i<length;i++)
{
cin>>array[i];
}
cout<<"最大子数组的和为:"<<getmax(array,length)<<endl;
cout<<"最大子数组起始下标:"<<getstartIndex(array,length)<<endl;
cout<<"最大子数组结束下标:"<<getendIndex(array,length)<<endl;
system("pause");
return 0;
}
operation result
unit test
Because I use vs2010, but found no vs2010 c ++ unit test module.
I checked the Internet some information and found that looks can be achieved indirectly standard C ++ unit testing, but I did not succeed to achieve.
I hope we can improve.
Blog work
You reviewed in the first two years of professional information and computing science learning experiences and project skills, write a resume about yourself, introduce your skills and prepare for future occupations, evaluate your current skills, abilities, whether competence, (evaluation of individual ability can refer to software engineers personal evaluation table https://www.cnblogs.com/xinz/p/3852177.html), and for future career development, as well as indicating what technical skills required in the subsequent year universities need to be strengthened.
Learned c ++, java, matlab and other programming languages in the first two years of college, computer-related courses contact data structures, operating systems, asp web design, database.
Basic stay at a basic level, there is no in-depth research, we can only solve some small problems. Data structures merely book knowledge level, there is no concept for practical applications.
Still learning, want to build knowledge and learning matlab and some other models, and try to learn some knowledge of data mining.