怎样用C++计算Georg Cantor表第n项值

2024-10-16 17:20:20

1、Georg Cantor表中各项的值如下图所示,第1项为1/1,第2项是1/2,第3项是2/1,第4项是3/1,第5项是2/2……,输入某一项的编号,就可以计算出该项的值。

怎样用C++计算Georg Cantor表第n项值

3、设置行数和某行前所有行的项数的初值,初值为0。

怎样用C++计算Georg Cantor表第n项值

5、用do-while语句执行循环,首先实现行数的累加。

怎样用C++计算Georg Cantor表第n项值

7、do-while语句的条件是,某一行之前所有项的总数,小于输入的项目编号。

怎样用C++计算Georg Cantor表第n项值

9、用if语句判断,如果为奇数行,所求项的分子为num=r+1-l,分母为den=l。

怎样用C++计算Georg Cantor表第n项值

11、最后,输出Georg Cantor表第n项的值,如下图所示。

怎样用C++计算Georg Cantor表第n项值
猜你喜欢