程序员 2008第一期 Cantor表 c#实现
2008-01-22 16:00
239 查看
public static void Cantor(int no)
{
int sum=0;
int i=0;
int n=0;
int mother=0;
int child=0;
for(i=0;;i++)
{
sum+=i;
n=no-sum;
if(n>0&&n<=i+1)
{
break;
}
}
if(i%2==1)
{
child=n;
mother=i+2-child;
}
else
{
mother=n;
child=i+2-mother;
}
string result=Convert.ToString(child)+"/"+Convert.ToString(mother);
Console.WriteLine(result);
}
{
int sum=0;
int i=0;
int n=0;
int mother=0;
int child=0;
for(i=0;;i++)
{
sum+=i;
n=no-sum;
if(n>0&&n<=i+1)
{
break;
}
}
if(i%2==1)
{
child=n;
mother=i+2-child;
}
else
{
mother=n;
child=i+2-mother;
}
string result=Convert.ToString(child)+"/"+Convert.ToString(mother);
Console.WriteLine(result);
}
相关文章推荐
- C# 你什么让程序员寂寞成酱紫 (男生版 娱乐中学习 抽象类 接口 继承 实现方法 )
- C#实现excel导入到sql server 2008(.net版)
- 我要为E语言程序员正名!同原理实现中文版C#
- 《领域驱动设计 C# 2008 实现》 - 书摘精要
- C#下实现SQL Server 2008表类型参数传递
- VS 2008 实现在C#中调用C++编写的 coin 3d 三位显示部分
- vs2008C#网页实现显示实时时间
- 老程序员学C# (一)------初识C# Visual Studio 2008
- 《领域驱动设计 C# 2008 实现》 - 书摘精要
- 【从业余项目中学习2】C# 实现调用Matlab函数(Visual Studio:2008, Matlab:R2009a)
- C#实现excel导入到sql server 2008(.net版)
- 引用数据库SQL Server 2008中数据时,如何实现C#.NET中的复选框?
- 《领域驱动设计 C# 2008 实现》 - 书摘精要
- C#实现的CRC16位校验
- C# 实现登录代码
- C#实现序列化和反序列化
- C# 实现自动ADSL拨号(基于bat)
- C#TextBox控件拖拽实现获得文件路径
- C# 实现telnet
- 《程序员的第一年》---------- 复习一下C#的【封装 多态 继承 -----简单计算器源码实例】