C++
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
vector<string> binaryTreePaths(TreeNode* root) {//返回vector<string>
vector<string>vc;
if(root==NULL){
return vc;
}
DFS(root,vc,to_string(root->val));
return vc;