zoukankan      html  css  js  c++  java
  • 牛客中的代码,写到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;
    }
  • 相关阅读:
    docker介绍与安装
    HTML5之Notification简单使用
    移动端实现复制内容至剪贴板
    flex基本概念
    nodejs建立websocket通信
    使用FileReader实现前端预览所选图片
    去除字符串中的空格
    用swing做一个简单的正则验证工具
    使用命令行生成jar包
    C#语言 语句
  • 原文地址:https://www.cnblogs.com/littleswan/p/11792181.html
Copyright © 2011-2022 走看看