收获:深度从上往下计数,根节点深度为1;
高度从下往上计数,叶节点高度为1
高度从下往上计数
sscanf的使用
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<unordered_map>
#include<map>
#include<queue>
using namespace std;
int main()
{
int p1, p2;
string s = "32 is the parent of 11";
if(s.find("parent") != s.npos)
{
sscanf(s.c_str(), "%d is the parent of %d", &p1, &p2);
printf("p1=%d,p2=%d", p1, p2);
}
}