题面
国外某知名 IT 企业有一个招聘题 :
Enter two strings, and , with length no more than , write code to check if is a rotation of .
在一行中输入 个字符串 和 ,字符串本身不含空格的字符串 (长度均不超过 ), 个字符串之间以 个空格分隔。
在一行中输出相关判断结果 (格式见例子)。
例如:
输入:waterbottle erbottlewat
输出:"waterbottle" is a rotation of "erbottlewat"
又如:
输入:water erbottlewat
输出:"water" is NOT a rotation of "erbottlewat"
/***************************************************************/
/* */
/* DON'T MODIFY main function ANYWAY! */
/* */
/***************************************************************/
#include <stdio.h>
#include <string.h>
int isRotation(char s1[],char s2[])
/* PreCondition: s1和s2是长度不超80的两个字符串
PostCondition: s2可以是s1经过循环移动后得到时返回1,否则0
*/
{
//TODO: your function definition
}
/***************************************************************/
#define N 80
int main()
{
char s[N+1],t[N+1];
scanf("%s%s",s,t);
//********** isRotation is called here *************
if(isRotation(s,t)) printf("\"%s\" is a rotation of \"%s\"\n",s,t);
else printf("\"%s\" is NOT a rotation of \"%s\"\n",s,t);
//**************************************************
return 0;
}
样例
输入
waterbottle erbottlewat
输出
"waterbottle" is a rotation of "erbottlewat"