Cantor的数表

import java.util.Scanner;
 
/**
 *
 *@author g0rez
 *@data 2021-07-14
 *
 */
public class Cantor的数表 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n,k,s;
        n=scanner.nextInt();
        while(n!=-1){//n==-1时结束
            k=0;
            s=0;
            while(s<n)
            {
                k++;
                s+=k;
            }
            if(k%2==1){
                System.out.println((s-n+1)+"/"+(k+n-s));
            }
            else{
                System.out.println((k+n-s)+"/"+(s-n+1));
            }
            n=scanner.nextInt();
        }
    }
}
 
posted @ 2021-07-25 22:17  guoyuxin3  阅读(38)  评论(0)    收藏  举报