• 牛客中的代码,写到codeblocks中。


    牛客中的代码都是封装好的库,然后我们就可以直接进行调用,像在牛客中使用容器,以及二叉树时,我们直接进行调用就行了,而不需要进行声明以及定义

    但是如果我们在复制牛客中的代码到其他的平台进行运行的时候,我们就需要考虑一下这个转化的问题。

    像vector,我们在使用的时候就需要进行声明。像二叉树,我们在使用的时候,需要进行定义。

    下面我举一个例子进行说明

    #include <vector>
    //#include<stdlib.h>
    #include<iostream>
    using namespace std;
    struct TreeNode
    {
        int val;
        TreeNode* left;
        TreeNode* right;
    };
    class Solution {
    public:
        vector<vector<int> > buffer;
        vector<int> tmp;
        vector<vector<int> > FindPath(TreeNode* root,int expectNumber) {
            if(root==NULL)
                return buffer;
            tmp.push_back(root->val);
            if((expectNumber-root->val)==0 && root->left==NULL && root->right==NULL)
                {
                buffer.push_back(tmp);
            }
            FindPath(root->left,expectNumber-root->val);
            FindPath(root->right,expectNumber-root->val);
            if(tmp.size()!=0)
                tmp.pop_back();
            return buffer;
        }
    
    };
    int main()
    {
            cout<<"现在是对了吗?"<<endl;
            cout<<"我真的是非常的开心了"<<endl;
            return 0;
    }
  • 相关阅读:
    NCBI SRA数据库使用详解
    自相关分析
    RandomAccessFile java
    手动安装R包
    ubuntu 设置环境变量
    Shell:Day09-2.笔记
    Shell:Day09.笔记
    Shell:Day08.笔记
    Shell:Day07.笔记
    Shell:Day06.笔记
  • 原文地址:https://www.cnblogs.com/littleswan/p/11792181.html
Copyright © 2020-2023  润新知