其他分享
首页 > 其他分享> > 【C实现】P1014 [NOIP1999 普及组] Cantor 表

【C实现】P1014 [NOIP1999 普及组] Cantor 表

作者:互联网

#include <stdio.h>
int main() {
    int given;
    int i = 1, is_odd = 0, fenzi = 0, fenmu = 0, sum;
    scanf("%d", &given);
    while(given > i){
        given -= i;
        i++;
    }
    if (given == 0){
        i--;

    }
    sum = i+1;
    if (i%2!=0){
        is_odd =1;
    }
    if (is_odd == 1){
        fenzi = sum - given;
        fenmu = sum - fenzi;
    }
    else{
        fenmu = given;
        fenzi = sum - fenmu;
    }
    printf("%d/%d\n", fenzi, fenmu);
    return 0;
}

标签:given,int,P1014,sum,Cantor,fenmu,NOIP1999,odd,fenzi
来源: https://blog.csdn.net/Markfieraloha/article/details/113704159