尼科彻斯定理

尼科彻斯定理的内容是 任何一个整数的立方都可以写成一串连续奇数的和

#include <stdio.h>

int main(void)
{

        int i,input_num,sum,temp_sum,temp_i,counts;

        scanf("%d",&input_num);

        sum = input_num * input_num * input_num;
        for(i=1;i<sum;i=i+2)
        {
                temp_sum = 0;
                temp_i = i;
                counts = 1;
                while(temp_sum < sum)
                {
                        temp_sum += temp_i;
                        if(temp_sum == sum) break;
                        temp_i += 2;
                        ++counts;
                }
                if(temp_sum == sum) break;
        }
        if(i >= sum){
                printf("--");
        } else {
                printf("%d -- %d = ",input_num,sum);
                for(i = 1; i < counts;i++)
                {
                        if(i != 1) printf(" + ");
                        printf("%d",temp_i - i*2);
                }
        }
        printf("\n");
        return 0;
}