读取字符串中的数字

x is the root:x是根结点;
x and y are siblings:x和y是兄弟结点;
x is the parent of y:x是y的父结点;
x is a child of y:x是y的一个子结点。

getline(cin,s);

s.find("parents")!=string::npos{
int x;
sscanf(s.c_str(),"%d is the root",&x);
}

posted on 2025-03-26 14:15  下头小美  阅读(21)  评论(0)    收藏  举报