数据结构中字符串的匹配
教材中一题。字符串匹配int main() { stack openings; char symbol; bool is_matched = true; while(is_matched&&(symbol=cin.get())!='\n') { if(symbol=='{'||symbol=='('||symbol=='[') openings.push(symbol); if(symbol=='}'||symbol==')'||symbol==']') { if(openings.empty()) { cout< match; openings.top(match); openings.pop(); is_matched=(symbol=='}'&&match;=='{') ||(symbol==')'&&match;=='(') ||(symbol==']'&&match;=='['); if(!is_matched) cout< ...展开详情收缩
用户评论