摘要: 1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 using namespace std; 6 7 /*从尾到头打印链表*/ 8 /* 9 题目:输入一个链表的头结点,从尾到头反过来打印出每个结点的值。10 */11 struct ListNode12 {13 int m_nValue;14 ListNode* m_pNext;15 };16 17 //根据后进先出的思想,考虑用栈的方法18 void PrintListReversingly_Iteratively(ListNode* pHead)19 ... 阅读全文
posted @ 2014-02-19 23:34 CrazyCode. 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 struct ListNode 7 { 8 int m_nValue; 9 ListNode* m_pnext;10 };11 12 void InsertNodeTail(ListNode** L,int num)13 {14 ListNode* node = new ListNode();15 node->m_nValue = num;16 node->m_pnext = NULL;17 if(... 阅读全文
posted @ 2014-02-19 23:23 CrazyCode. 阅读(422) 评论(0) 推荐(0) 编辑
摘要: 1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 /*替换空格*/ 7 /* 8 题目:请实现一个函数,把字符串中的每个空格替换成"%20".例如输入"We are happy",则输出"We%20are%20happy". 9 */10 int ReplaceBlank(char string[],int length)11 {12 int i = 0;13 int blankNum=0;14 int strLength= 阅读全文
posted @ 2014-02-19 20:45 CrazyCode. 阅读(575) 评论(0) 推荐(0) 编辑
摘要: 1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 /*二维数组中的查找*/ 7 /* 8 题目: 9 在一个二维数组中,每一行都按照从左到右递增的顺序排序,10 每一列都按照从上到下递增的顺序排序.请完成一个函数,11 输入这样的一个二维数组和一个整数,12 判断数组中是否含有该整数.13 */14 bool FindNumber(int *matrix,int columns,int rows,int key)15 {16 bool found = false;17 if(ma.. 阅读全文
posted @ 2014-02-19 13:45 CrazyCode. 阅读(170) 评论(0) 推荐(0) 编辑