您的位置:首页 > 职场人生

程序员 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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c# string