1.求前N个自然数之和
int Sum(int n)
{
if(n==1)
return 1;
return n+Sum(n-1);
}2.求N的阶乘
int Factorial(int n)
{
if(n==1)
return 1;
return n*Factorial(n-1);
}
3.逆序打印单链表
struct Node
{
Node* _next;
int value;
};
void ReversedPrint(Node* pHead)
{
if(pHead==NULL)
return ;
if(pHead)
{
ReversedPrint(pHead->_next);
cout<<pHead->value<<" ";
}
}
4.逆序销毁单链表
struct Node
{
Node* _next;
int value;
};
void Destory(Node*& pHead)
{
if(pHead==NULL)
return ;
if(pHead)
{
Destory(pHead->_next);
pHead=NULL;
}
}
5.在单链表中逆序查找某个值为data的结点
struct Node
{
Node* _next;
int value;
};
Node* Revers

最低0.47元/天 解锁文章
5190

被折叠的 条评论
为什么被折叠?



