|
|
back to boardWhy Compliation Error?? plz check my program... #include<stdio.h> #include<math.h> int main() { long n,a,p,x,chk=0,sum=0; scanf("%ld",&n); for(x=sqrt(n);chk==0;x++) { if(x*(x+1)/2>n) { break; } } for(chk=0;x<=n/2+1;x++) { for(p=1;sum<n;p++) { sum+=x+1-p; if(sum==n) { a=x+1-p; x=n/2+2; chk=1; break; } } sum=0; } if(chk==1) printf("%ld %ld",a,p); return 0; } Re: Why Compliation Error?? Your source have some problem about sqrt fuction. I think you have to use sqrt((double)n); |
|
|