栈  0.1
数据结构_第3章
Akm_t Class Reference

实现AckerMann函数。 More...

#include <Ackermann.hh>

Collaboration diagram for Akm_t:
[legend]

Public Member Functions

 Akm_t (std::string name="name")
 Construct a new Akm_t object. More...
 
 ~Akm_t ()=default
 Destroy the Akm_t object. More...
 

Static Public Member Functions

static void Akm_loop (int x, int y)
 堆栈版本的Ackermann函数 More...
 
static void Akm_rec (int x, int y)
 递归版本的Ackermann函数 More...
 

Static Private Member Functions

static int Ackermann (int m, int n)
 Ackermann函数递归版本 More...
 
static int AckermannLoop (int m, int n)
 Ackermann函数堆栈模拟递归版本 More...
 
static void AkmInit ()
 初始化类内部的静态计数器 More...
 

Private Attributes

std::string _name
 对象标识 More...
 

Static Private Attributes

static int Akm_deep = 0
 记录当前递归深度 More...
 
static int deep_max = 0
 记录最大递归深度 More...
 

Detailed Description

实现AckerMann函数。

两种方式:

  • 递归调用(系统栈)
  • 堆栈模拟(堆栈)

Definition at line 31 of file Ackermann.hh.

Constructor & Destructor Documentation

◆ Akm_t()

Akm_t::Akm_t ( std::string  name = "name")
inline

Construct a new Akm_t object.

Parameters
name对象标识符.

传入的参数不会被使用

Definition at line 82 of file Ackermann.hh.

◆ ~Akm_t()

Akm_t::~Akm_t ( )
default

Destroy the Akm_t object.

Member Function Documentation

◆ Ackermann()

int Akm_t::Ackermann ( int  m,
int  n 
)
staticprivate

Ackermann函数递归版本

是工具函数

Parameters
m第一个参数, 建议取1 ~ 4
n第二个参数, 建议取1 ~ 13
Returns
int 计算结果

Definition at line 150 of file Ackermann.hh.

References Akm_deep, and deep_max.

Referenced by Akm_rec().

Here is the caller graph for this function:

◆ AckermannLoop()

int Akm_t::AckermannLoop ( int  m,
int  n 
)
staticprivate

Ackermann函数堆栈模拟递归版本

是工具函数

Parameters
m第一个参数, 建议取1 ~ 4
n第二个参数, 建议取1 ~ 13
Returns
int 计算结果

Definition at line 179 of file Ackermann.hh.

References Akm_deep, deep_max, Stack::seqStack< T >::elemMem(), Stack::seqStack< T >::isEmpty(), Stack::seqStack< T >::pop(), Stack::seqStack< T >::push(), Stack::seqStack< T >::size(), and Stack::seqStack< T >::top().

Referenced by Akm_loop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Akm_loop()

void Akm_t::Akm_loop ( int  x,
int  y 
)
static

堆栈版本的Ackermann函数

Parameters
x参数1, 建议取1 ~ 4
y参数2, 建议取1 ~ 13

将会半实时刷新当前堆栈深度。当最大深度增加时, 刷新显示内容

Definition at line 117 of file Ackermann.hh.

References AckermannLoop(), and AkmInit().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Akm_rec()

void Akm_t::Akm_rec ( int  x,
int  y 
)
static

递归版本的Ackermann函数

Parameters
x参数1, 建议取1 ~ 4
y参数2, 建议取1 ~ 13

将会半实时刷新当前递归深度。当最大深度增加时, 刷新显示内容

Definition at line 132 of file Ackermann.hh.

References Ackermann(), Akm_deep, AkmInit(), and deep_max.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AkmInit()

static void Akm_t::AkmInit ( )
inlinestaticprivate

初始化类内部的静态计数器

Definition at line 68 of file Ackermann.hh.

References Akm_deep, and deep_max.

Referenced by Akm_loop(), and Akm_rec().

Here is the caller graph for this function:

Member Data Documentation

◆ _name

std::string Akm_t::_name
private

对象标识

无实际作用

Definition at line 40 of file Ackermann.hh.

◆ Akm_deep

int Akm_t::Akm_deep = 0
staticprivate

记录当前递归深度

Definition at line 70 of file Ackermann.hh.

Referenced by Ackermann(), AckermannLoop(), Akm_rec(), and AkmInit().

◆ deep_max

int Akm_t::deep_max = 0
staticprivate

记录最大递归深度

Definition at line 71 of file Ackermann.hh.

Referenced by Ackermann(), AckermannLoop(), Akm_rec(), and AkmInit().


The documentation for this class was generated from the following file: