// ConsoleApplication12.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
// ConsoleApplication12.cpp : 定义控制台应用程序的入口点。
//
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
using namespace std;
class Bonus {
public:
int getMost(vector<vector<int> > board) {
// write code here
int sum=0;
if (board.size() == 1) //行等于1
{
for (int i = 0;i < board[0].size();++i)
{
sum = accumulate(board[0].begin(),board[0].end(),0);
}
return sum;
}
if (board[0].size() == 1) //列等于1
{
for (int i = 0;i < board.size();++i)
{
sum = sum + board[i][0];
}
return sum;
}
return sum+ max(getMostLowRow( board) , getMostLowCol(board))+ board[0][0];
}
int getMostLowRow(vector<vector<int> > board) {
//删除行
board.erase(board.begin());
return getMost(board);
}
int getMostLowCol(vector<vector<int> > board) {
//删除列
for (int i = 0;i < board.size();++i)
{
board[i].erase(board[i].begin());
}
return getMost(board);
}
};
int main()
{
vector<int> vec1 = { 1,2 };
vector<int> vec2 = { 3,4 };
vector<vector<int>> vec;
vec.push_back(vec1);
vec.push_back(vec2);
Bonus bo;
cout<<"所获取的最大值为:"<<bo.getMost(vec);
cout << endl;
return 0;
}
//这种一般用回归