strrev无法编译时什么操作,不是标准函数吗?

/in/foo.c: In function 'test':
/in/foo.c:9:5: warning: implicit declaration of function 'strrev' [-Wimplicit-function-declaration]
strrev(x);
^~~~~~
/in/foo.c: In function 'main':
/in/foo.c:22:22: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int' [-Wformat=]
printf("%s\n",strrev(mw[i]));
^
/tmp/ccR9Tj67.o: In function test':
foo.c:(.text+0x3e): undefined reference to
strrev'
/tmp/ccR9Tj67.o: In function main':
foo.c:(.text.startup+0xaf): undefined reference to
strrev'
collect2: error: ld returned 1 exit status

#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=10000+10;
char mw[3][maxn];

bool test(int a,int b,int c,int n)
{
    char x[maxn];
    memcpy(x,mw[a],sizeof(mw[a]));
    strrev(x);
    for(int i=0;i<n;i++)
        if((mw[b][i]-'a'+mw[c][i]-'a')%26!=2*(x[i]-'a')%26) return false;
    return true;
}
int main()
{
    //freopen("input.txt","r",stdin);
    int n;
    scanf("%d",&n);
    scanf("%s%s%s",mw[0],mw[1],mw[2]);
    for(int i=0;i<3;i++)
        if(test(i,(i+1)%3,(i+2)%3,n)){
            printf("%s\n",strrev(mw[i]));
            break;
        }
    return 0;
}

3 条评论

  • @ 2017-08-01 19:43:36

    貌似还真不是标准里的,应该是编译器自己加的扩展
    标准里的只有这些:http://www.cplusplus.com/reference/cstring/

    • @ 2017-08-01 20:30:01

      恩恩,之后是自己写了一个转置函数,通过了,我一直以为是标准的呢。哈哈

  • @ 2017-08-01 17:47:35

    您可以使用

    string mw;
    reverse(mw.begin(),mw.end());
    
    • @ 2017-08-01 20:30:56

      恩恩,这个也知道,只不过没想到strrev这个竟然不是标准的,痛苦

  • @ 2017-08-01 16:39:17

    不是啊233

  • 1

信息

ID
1449
难度
6
分类
字符串 | 模拟 点击显示
标签
递交数
6903
已通过
1850
通过率
27%
被复制
9
上传者