|
- #include <stdio.h>
- #include <math.h>
- int loop(int x)
- {
- int y = 0;
- for (; x != 0; x /= 10)
- y = y * 10 + x % 10;
- return y;
- }
-
- int prime(int x)
- {
- int i, sqx;
- sqx = sqrt(x);
- for (i = 1; i <= sqx; i++)
- if (x % i == 0)
- break;
- if (i >= sqx)
- return 1;
- else
- return 0;
- }
-
-
- int main()
- {
- int i, n;
- scanf ("%d", &n);
- if (prime(n) == 1 && prime(loop(n)) == 1)
- printf ("yes");
- else
- printf ("no");
- return 0;
- }
复制代码
这个是一个验证可逆素数的程序,我的问题是,在VC下编译通过,但在linux下用gcc编译,会出现如下信息:
- /tmp/ccgom8l8.o(.text+0x6e): In function `prime':
- : undefined reference to `sqrt'
- collect2: ld returned 1 exit status
复制代码
请问其中原因?谢谢. |
|