编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#3688 #1010. 击毙你~~~ Compile Error 0 0 ms 0 K C / 1.1 K t330026189 2023-11-25 16:21:01
显示原始代码
#include <stdio.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define L 50005

char s1[L] = "\0", str[L][L] = { "\0" }, buff[L * 2] = "\0";
int find(char str[], int len);
long long len1;
int main(int argc, char** argv) {
    long long n, len, cont = 0;
    scanf("%lld %s", &n, s1);
    len1 = strlen(s1);
    for (long long k = 0; k < n; k++) {
        scanf("%s", str[k]);
        sprintf(buff, "%s%s", str[k], str[k]);
        len = strlen(buff);
        if (find(buff, len)) {
            cont++;
        }
        //	getchar();
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            sprintf(buff, "%s%s", str[i], str[j]);
            len = strlen(buff);
            if (find(buff, len)) {
                cont++;
            }
            sprintf(buff, "%s%s", str[j], str[i]);
            len = strlen(buff);
            if (find(buff, len)) {
                cont++;
            }
        }
    }
    printf("%d\n", cont);
    return 0;
}
int find(char str[], int len)  // len1 could use derectly
{
    if (len1 > len)
        return 0;
    int i = 0, j = 0;
    for (; i < len; i++) {
        if (str[i] == s1[j])
            j++;
    }
    if (j == len1)
        return 1;
    return 0;
}

编译信息

/sandbox/1/a.c:44:16: warning: format specifies type 'int' but the argument has type 'long long' [-Wformat]
        printf("%d\n",cont);
                ~~    ^~~~
                %lld
1 warning generated.
/tmp/a-59eac1.o: in function `main':
a.c:(.text+0x31): relocation truncated to fit: R_X86_64_PC32 against symbol `len1' defined in .bss section in /tmp/a-59eac1.o
a.c:(.text+0xa3): relocation truncated to fit: R_X86_64_PC32 against symbol `len1' defined in .bss section in /tmp/a-59eac1.o
a.c:(.text+0xe4): relocation truncated to fit: R_X86_64_32S against symbol `buff' defined in .bss section in /tmp/a-59eac1.o
a.c:(.text+0xfb): relocation truncated to fit: R_X86_64_32S against symbol `buff' defined in .bss section in /tmp/a-59eac1.o
a.c:(.text+0x114): relocation truncated to fit: R_X86_64_32S against symbol `buff' defined in .bss section in /tmp/a-59eac1.o
a.c:(.text+0x12d): relocation truncated to fit: R_X86_64_32S against symbol `buff' defined in .bss section in /tmp/a-59eac1.o
a.c:(.text+0x155): relocation truncated to fit: R_X86_64_32S against symbol `buff' defined in .bss section in /tmp/a-59eac1.o
a.c:(.text+0x234): relocation truncated to fit: R_X86_64_PC32 against symbol `len1' defined in .bss section in /tmp/a-59eac1.o
a.c:(.text+0x274): relocation truncated to fit: R_X86_64_32S against symbol `buff' defined in .bss section in /tmp/a-59eac1.o
a.c:(.text+0x28c): relocation truncated to fit: R_X86_64_32S against symbol `buff' defined in .bss section in /tmp/a-59eac1.o
a.c:(.text+0x2a4): additional relocation overflows omitted from the output
clang: error: linker command failed with exit code 1 (use -v to see invocation)