淘先锋技术网

首页 1 2 3 4 5 6 7

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

对7帖做一更正:删除

if(iCount*iCount==2*liDate) break; 

这一句,不然程序会认为18,50,72之类的数无解.

改正后的程序如下:

#include

#include

main()

{

long liDate; 

long iCount;

long i,min,max;

int flag=0;

system("cls");

printf("Please inout the number:\n",&liDate);

scanf("%ld",&liDate);

for(iCount=(long)sqrt(2*liDate);iCount>=2;iCount--)

if(2*liDate%iCount==0)

if(iCount%2) 

{

flag=1;

min=liDate/iCount-(iCount-1)/2;

max=liDate/iCount+(iCount-1)/2;

for(i=min;i<=max;i++)

printf("%ld ",i);

printf("\n\n");

}

else if(2*liDate/iCount%2) 

{

flag=1;

min=liDate/iCount-iCount/2+1;

max=liDate/iCount+iCount/2;

for(i=min;i<=max;i++)

printf("%ld ",i);

printf("\n\n");

}

printf("\n");

if(flag==0) printf("NONE\n");

system("pause");

}