文章
17
粉丝
177
获赞
2
访问
118.3k
#include<iostream>
using namespace std;
string larger_than_root(string s){ //计算比根大的子串
int start_pos = 0;
while(start_pos < s.length()){
if(s[start_pos] > s[0]) break;
else start_pos++;
}
int end_pos = start_pos + 1;
while(end_pos < s.length()){
if(s[end_pos] < s[0]) break;
else end_pos++;
}
return s.substr(start_pos, end_pos - start_pos);
}
string lower_than_root(string s){ //计算比根小的字串
int start_pos = 0;
while(start_pos < s.length()){
if(s[start_pos] < s[0]) break;
else start_pos++;
}
int end_pos = start_pos + 1;
while(end_pos < s.length()){
if(s[end_pos] > s[0]) break;
else end_pos++;
}
return s.substr(start_pos, end_pos - start_pos);
}
bool is_same_search_tree(string s1,string s2){
if(s1.length() != s2.length()) return false; //如果长度都不相等肯定不是
else if(s1.length() == 0){ //都是长度为零,肯定是
...
登录后发布评论
暂无评论,来抢沙发