max sum of sequence(序列最大和)

作者:袖梨 2022-07-02

#include

using namespace std;

int main(int argc, char *argv[])
{
    int n;

    cin >> n;
    const int maxlen = n;

    int s[maxlen];
    int arr[maxlen][maxlen];
   
    for (int i = 0; i < maxlen; i++)
    {
        cin >> s[i];
    }

     ////////////////////////////////////
     //方案一
    /*

    for( int i = 0; i < maxlen; i++)
    {
        for (int j = 0; j < i; j++)
        {
            arr[j][i] = arr[j][i-1] + s[i];
        }
        arr[i][i] = s[i];
    }
   
    int max = 0;
    for (int i = 0; i < maxlen; i++)
    {
        for (int j = 0; j <= i ; j++)
        {
            cout << arr[j][i] << "  ";
                  if ( arr[j][i] > max)
                  {
                    max = arr[j][i];
                  }
        }
        cout << endl;
    }
   
    cout << max << endl;
    */
    /////

相关文章

精彩推荐