网易秋招编程题——回文序列
2016-10-17 23:17
197 查看
“test.cpp”
<strong><span style="font-size:18px;">#include<iostream>
using namespace std;
int comb(int* nums,int start,int end)
{
int count = 0;
int left = nums[start];
int right = nums[end];
while(start < end && left != right)
{
if(left < right)
{
left += nums[++start];
count++;
}
else
{
right += nums[--end];
count++;
}
}
if(start > end)
{
return count;
}
else
{
return count += comb(nums,++start,--end);
}
}
void test()
{
int n = 0;
int nums[50] = {0};
cin>>n;
for(int i = 0;i < n;i++)
{
cin>>nums[i];
}
cout<<comb(nums,0,n-1)<<endl;
}
int main()
{
test();
return 0;
}</span></strong>
相关文章推荐
- 网易编程题一,回文序列(贪心法)
- 网易2017秋招编程题:回文序列 [python]
- 网易2017秋招编程题----回文序列
- 【Python】 易笔试编程题(回文序列)
- 网易2017校招 [编程题] 最长公共子括号序列@Java
- 统计回文(string.insert的应用,insert只能插入string,不能插入char)----网易2017内推笔试编程题合集(二)
- 网易编程题--操作序列
- 网易2017校园招聘笔试题:回文序列
- 网易真题之回文序列
- 网易笔试题:回文序列
- python字符串split(),join(),strip()函数及网易笔试 回文序列
- 网易2017内推 [编程题]操作序列@Java
- 网易2017秋招 回文序列
- 网易笔试编程题:统计回文(C++)
- 网易笔试题:回文序列
- 网易2018校招编程题 操作序列(C++)
- 网易真题之回文序列
- 网易-回文序列
- 网易编程题 操作序列
- 网易内推笔试编程题-字符串子序列判断