[C]为什么洛谷显示编译不成功呢?(vs2022编译没问题)

P1217 [USACO1.5] 回文质数 Prime Palindromes

foxr001 @ 2022-12-23 20:44:15

#include <stdio.h>
#include <math.h>
int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    int i, j, k, p=0;
    int c, d;
    char a1[10] = { 0 };
    for (i = a; i <= b; i++)
    {
        c = 0;
        d = i;
        j = 0;
        while (1)
        {
            c = d % 10;
            d /= 10;
            a1[j] = c;
            j++;
            if (d == 0)
                break;
        }
        if (j != 4 && j != 6 && j != 8)
        {
            if (i <= 1)
                c=0;
            if (i == 5)
                c=1;
            if (i % 2 == 0 || i % 3 == 0)
                c=0;
            else
            {
                for (k = 6; k <= sqrt(double(i)); k += 6)
                {
                    if (i % (k - 1) == 0 || i % (k + 1) == 0)
                        break;
                }
                if (k = sqrt(double(i)))
                    c = 1;
            }
            j--;
            if (c == 1)
            {

                c = 0;
                for (k = 0; k <= j - k; k++)
                {
                    if (a1[k] != a1[j - k])
                    {
                        c = 1;
                        break;
                    }
                }
                if (c == 0)
                {
                    printf("%d\n", i);
                }
            }
        }
    }
    return 0;
}

by tin_ingot @ 2022-12-23 20:52:51

@foxr001 语言选择c++


by Hisaishi_Kanade @ 2022-12-23 21:04:28

double(...)\to(double)(...)


by Hisaishi_Kanade @ 2022-12-23 21:05:30

前者大概是构造函数的写法,C不支持吧


by foxr001 @ 2022-12-24 08:40:35

ok,解决了,感谢


|