![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Algorithm Practice
武汉小锋
我是一个程序员
展开
-
圈人数数:An interesting way to delete numbers
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace choice{ class Program { static void Main(string[] args) { int count=0;原创 2009-06-04 14:56:00 · 445 阅读 · 0 评论 -
合并两链表:LinkList:Merge Two LinkList using the general method
// LinkList.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;typedef struct _node{ int val; struct _node* next;}Node; Node*原创 2009-12-03 10:44:00 · 491 阅读 · 0 评论 -
数字转换为字符串:String:convert an int to a string
// QuickSort.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;char* ltoa( int n){ int count=0; int m=n; int l=1; if(m { count++;原创 2009-12-02 16:29:00 · 429 阅读 · 0 评论 -
翻转链表:LinkList:Reverse a LinkList has some interesting method(C++)
// LinkList.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;typedef struct _node{ int val; struct _node* next;}Node; Node原创 2009-12-03 10:02:00 · 362 阅读 · 0 评论 -
递归合并两链表:LinkList:Merge Two Lists using recursive method
// LinkList.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;typedef struct _node{ int val; struct _node* next;}Node; Node*原创 2009-12-03 11:04:00 · 317 阅读 · 0 评论 -
非递归交换二叉树左右子树:BinaryTree:Exchange the left child and the right child without recursive method
// BTree.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"#include "stack"using namespace std;typedef struct _node{ int data; struct _node* rch; st原创 2009-12-05 13:52:00 · 587 阅读 · 0 评论 -
递归交换二叉树左右子树:BinaryTree:Exchange the left child and right child of a binary tree
// BTree.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;typedef struct _node{ int data; struct _node* rch; struct _node* lch;原创 2009-12-05 11:46:00 · 532 阅读 · 0 评论 -
C++链表实现堆栈:LinkList:Build a linklist using C++ class Stack
// Stack.cpp : Defines the entry point for the console application. #include "stdafx.h"#include "iostream"using namespace std;typedef struct_node intdata;原创 2009-12-09 16:07:00 · 433 阅读 · 0 评论 -
遍历目录
#include "stdafx.h"#include "windows.h"#include "string.h"#include "time.h" //clock()#define MAX 1000int level = 0;int filecount = 0;void Findfile(char * filepath); int _tmain(int argc, _TCHA原创 2010-04-13 12:31:00 · 364 阅读 · 0 评论 -
Copy Directory
#include "stdafx.h"#include "windows.h"#include "string.h"#include "time.h" //clock()#define MAX 1000int level = 0;int filecount = 0;void Findfile(char * filepath,char *destpath); int _tmain(原创 2010-04-14 08:42:00 · 466 阅读 · 0 评论 -
Josephu问题的链表解决方案
<br />typedef struct Node<br />{<br /> int index;<br /> struct Node *next;<br />}JosephuNode;<br /><br />int Josephu(int n, int m)<br />{<br /> int i, j;<br /> JosephuNode *head, *tail;<br /> head = tail = (JosephuNode *)malloc(sizeof(JosephuNode));<b原创 2010-06-07 10:17:00 · 561 阅读 · 0 评论 -
内存拷贝函数
<br />void* memcpy( void *dst, const void *src, unsigned int len )<br />{<br /> register char *d;<br /> register char *s;<br /> if (len == 0)<br /> return dst;<br /> if ( dst > src ) //考虑覆盖情况<br /> {<br /> d = (char *)dst + l原创 2010-06-07 11:13:00 · 310 阅读 · 0 评论 -
全排列:String:Permutation using C++
// Permutation.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;void OutCh(char ch[]){ int len=sizeof(ch)/sizeof(char); for(int原创 2009-12-02 17:11:00 · 454 阅读 · 0 评论 -
字符串转换为数字:String:convert a string to int
#include "stdafx.h"#include "iostream"using namespace std;long int atol(char *c){ int count=0; int val=1; int l=0; if(*c==-) { c++; val=-1; } while(*c!=/0) { l=l*10+(*c)-0; c++; } r原创 2009-12-02 15:14:00 · 298 阅读 · 0 评论 -
中序遍历二叉排序树:BinarySearchTree:Create a tree and InorderTree
// BinaryTree.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;typedef struct _node{ struct _node* lch; struct _node* rch; int原创 2009-12-04 10:44:00 · 447 阅读 · 0 评论 -
写窗体:c++ WINDOW:There are so many definitions of a window
#includeLRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){ WNDCLASS wndclass; HWND hwnd; MSG msg; wndcl原创 2009-08-14 15:55:00 · 240 阅读 · 0 评论 -
选择排序:SelectSort:select the minimum every time
using System;namespace SelectSort{ class program { static void Main() { int[] arr={12,67,2,90,45,67,23,67}; int len=arr.Length; int min,index; for(int i=0;i { m原创 2009-06-21 00:07:00 · 224 阅读 · 0 评论 -
插入排序:InsertSort:no more than ten lines
using System;namespace insertsort{ class program { static void Main() { int[] arr={56,12,4,89,42,45,4,89}; int len=arr.Length; for(int i=1;i {原创 2009-06-21 21:52:00 · 229 阅读 · 0 评论 -
二义性:Common Base Class
// virtualbase.cpp : Defines the entry point for the console application.//#include "stdafx.h"#includeusing namespace std;class A{protected: int a;public: A(int aa):a(aa) {} ~A(void) {}};class B:v原创 2009-06-24 09:35:00 · 389 阅读 · 0 评论 -
自己实现全排列:I found some old code were good:We should think in a reverse way
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace zuhe{ class Program { static public void zuhe(char[] c, StringBuilder s, int level) {原创 2009-06-23 16:30:00 · 265 阅读 · 0 评论 -
冒泡排序设标志避免重复:Sort:Bubble Sort using tag and Xor operation
// AlgTest.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;int _tmain(int argc, _TCHAR* argv[]){ int a[9]={12,34,2,78,1,78,34原创 2009-11-29 00:59:00 · 380 阅读 · 0 评论 -
归并排序:Sort:Merge sort using temporary int array(c++)
// AlgTest.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;void MergeSort(int a[],int temp[],int start,int end){ if(start {原创 2009-11-29 00:23:00 · 336 阅读 · 0 评论 -
异或翻转字符串:String:Improve my method of reverse a string
// TestString.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"#include "string"using namespace std;int _tmain(int argc, _TCHAR* argv[]){ char s[]原创 2009-11-29 03:22:00 · 336 阅读 · 0 评论 -
堆栈选择性翻转字符串:String:Reverse a string using Stack:the pointer is a very good tool actually
// TestString.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"#include "string"#include "stack"using namespace std;int _tmain(int argc, _TCHAR* a原创 2009-11-29 04:29:00 · 447 阅读 · 0 评论 -
快速排序:Sort:QuickSort using C++
// QuickSort.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;void QuickSort(int num[],int low,int high){int pivot=num[low];int i原创 2009-12-02 10:34:00 · 302 阅读 · 0 评论 -
链表插入排序:LinkList:Sort a LinkList(insert directly)
// ListSort.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;typedef struct _node{ int data; struct _node *next;}Node;int _tm原创 2009-12-03 17:31:00 · 856 阅读 · 0 评论 -
堆排序
<br />// array是待调整的堆数组,i是待调整的数组元素的位置,length是数组的长度 <br /> void HeapAdjust(int array[], int i, int nLength) <br /> { <br /> int nChild, nTemp; <br /> for (nTemp = array[i]; 2 * i + 1 < nLength; i = nChild) <br />原创 2010-06-07 15:11:00 · 240 阅读 · 0 评论