摘要: 常规解法:int trim(char* str){ int count = 0; char* p = str; bool first = true; while(*str != '\0' && *str == ' '){ count++; str++; } if(*str == '\0'){ *p = '\0'; return count; } while(*str != '\0'){ while(*str... 阅读全文
posted @ 2012-09-25 22:22 Itachi7 阅读(2459) 评论(0) 推荐(0) 编辑
摘要: 递归转非递归 几乎都是用栈, 前序和中序遍历比较简单 ,后序遍历稍麻烦;1. 前序遍历 :void preDis(NODE* head) //前序遍历{ NODE* temp = head; stack<NODE*> st; while (temp != NULL||!st.empty()) { while (temp != NULL) //当前非空 { cout<<temp->val<<' '; //访问 ... 阅读全文
posted @ 2012-09-25 10:20 Itachi7 阅读(299) 评论(0) 推荐(0) 编辑