摘要:
部分参考http://blog.csdn.net/niuer09/article/details/5961004要求将一带链表头List head的单向链表逆序。分析: 1). 若链表为空或只有一个元素,则直接返回;2). 设置两个前后相邻的指针p,q. 将p所指向的节点作为q指向节点的后继; 3). 重复2),直到q为空 4). 调整链表头和链表尾示例:以逆序A->B->C->D为例,图示如下#include "stdafx.h"#include using namespace std;struct node{ int data; struct node 阅读全文
摘要:
一个字符串“aasbbsdsskkff”,求出重复的次数,并写到数组后面,输出为“a2s1b2s1d1s2k2f2”#include "stdafx.h"#include using namespace std;int _tmain(int argc, _TCHAR* argv[]){ char str[]="aasbbsdsskkff"; char *out=new char [strlen(str)+10]; int i=0,j=0; int count=1; while(str[i]!='\0') { if(str[i]==str[ 阅读全文