社区讨论

编译失败!大神看过来

P1308[NOIP 2011 普及组] 统计单词数参与者 4已保存回复 4

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
4 条
当前快照
1 份
快照标识符
@mi6hkoa8
此快照首次捕获于
2025/11/20 05:00
4 个月前
此快照最后确认于
2025/11/20 05:00
4 个月前
查看原帖
CPP
#include <stdio.h>
#include <string.h>
int main()
{
    char c,word[15],thisword[15],article[1000005];
    int i,j=0,flag=0,ans=0;
    gets(word);
    gets(article);
    strlwr(word);
    strlwr(article);
    strcat(article," ");
    for(i=0; i<strlen(article); i++)
    {
        c=article[i];
        if(c!=' ')
        {
            thisword[j++]=c;
            flag=1;
        }
        else if(flag)
        {
            thisword[j]='\0';
            if (!strcmp(word,thisword))ans++;
            flag=0;
            j=0;
        }
    }
    if(!ans)ans=-1;
    printf("%d",ans);
    return 0;
}
在我自己电脑上可以编译通过的,上传后编译失败
/tmp/tmpjCjsg1.c: In function 'main':
/tmp/tmpjCjsg1.c:8:5: warning: 'gets' is deprecated (declared at /tmp/runtime/include/stdio.h:638) [-Wdeprecated-declarations]
gets(word);
^ /tmp/tmpjCjsg1.c:9:5: warning: 'gets' is deprecated (declared at /tmp/runtime/include/stdio.h:638) [-Wdeprecated-declarations]
gets(article);
^ /tmp/tmpjCjsg1.c:10:5: warning: implicit declaration of function 'strlwr' [-Wimplicit-function-declaration]
strlwr(word);
^ /tmp/ccZjcsU5.o: In function `main':
tmpjCjsg1.c:(.text+0x49): undefined reference to `strlwr'
tmpjCjsg1.c:(.text+0x5d): undefined reference to `strlwr'
collect2: error: ld returned 1 exit status

回复

4 条回复,欢迎继续交流。

正在加载回复...