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(); } } }
本文来自博客园,作者:guoyuxin3,转载请注明原文链接:https://www.cnblogs.com/guoyuxin3/p/15059245.html

浙公网安备 33010602011771号