|
|
вернуться в форумWHY COMPILE ERROR????HELP PLZ!!!! I can't understand why I get compile error! I don't see nothing strange in my code and it works perfectly in my computer, so I don't know what to change here is my code: #include <stdio.h> #include <math.h> int p[15003],ind=5; is_prime(int n){ int i=3,l=sqrt(n)+1; while(i<l){ if(n%i==0) return 0; i+=2; } return 1; } init(){ int i; for(i=11;ind<15002;i+=2){ if(is_prime(i)){ p[ind]=i; ind++; } } } int main() { p[1]=2;p[2]=3;p[3]=5;p[4]=7; int n,i,k; init(); scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%d",&k); printf("%d\n",p[k]); } return 0; } is someone can help me I would appreciate.... thanks! bye Re: WHY COMPILE ERROR????HELP PLZ!!!! Put SQRTL instead of SQRT and you'll get AC... Re: WHY COMPILE ERROR????HELP PLZ!!!! thanks for your reply but I try it by changing "sqrt" for "sqrtl" and it doesn't work maybe it is something else thanks anyway! byee Re: WHY COMPILE ERROR????HELP PLZ!!!! I submitted your source with C++ and sqrtl and got AC... Re: WHY COMPILE ERROR????HELP PLZ!!!! yes you are right I submit it but in C so I get compilation error thanks :D !!!!! Re: WHY COMPILE ERROR????HELP PLZ!!!! Послано Akob 24 мар 2007 13:46 (int)sqrt((double)n)-it is a true Re: WHY COMPILE ERROR????HELP PLZ!!!! while (i*i<=n) - it's true or i = 0; while (p[i]*p[i]<=n)... |
|
|