- 字符串还原
- 2017-08-01 15:35:34 @
/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':
strrev'
foo.c:(.text+0x3e): undefined reference to
/tmp/ccR9Tj67.o: In function main':
strrev'
foo.c:(.text.startup+0xaf): undefined reference to
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 条评论
-
Orina_zju LV 8 @ 2017-08-01 19:43:36
貌似还真不是标准里的,应该是编译器自己加的扩展
标准里的只有这些:http://www.cplusplus.com/reference/cstring/ -
2017-08-01 17:47:35@
您可以使用
string mw; reverse(mw.begin(),mw.end());
-
2017-08-01 16:39:17@
不是啊233
- 1