这道题根据题意就可以写了;只不过需要注意的是string类的常用函数我得复习一下,嘻嘻;
1.s.length()//返回长度
2.s.empty()//判断是不是空串,返回true or false;
3.s.insert(pos,s2)//在s中下标为pos的位置插入串s2
4.s.erase(pos,n); 删除从pos开始的n个字符,比如erase(0,1)就是删除第一个字符
5.s.find()//参数可以是另一个串或者字符,如果找到,那么久返回第一个对应的下标,如果没有找到返回-1;
6.operator=//可以字符串赋值;
7.operator+=//字符串相加;
8.operator==或者!=或者>或者<;
这就是经常用的了;
所以AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
string T,s;
cin>>T;
int len1=T.length();
int n;
scanf("%d",&n);
while(n--){
cin>>s;
int len2=s.length();
if(len1>len2){//根据题意分情况讨论就完了,这里没啥说的
if(T.find(s)!=-1){
puts("my child!");
}else{
puts("oh, child!");
}
}else if(len1<len2){
if(s.find(T)!=-1){
puts("my teacher!");
}else{
puts("senior!");
}
}else{
if(T==s)puts("jntm!");
else puts("friend!");
}
}
return 0;
}