1888 可译编码

可译编码
strstr(s1,s2)函数判断s2是否是s1的字串,返回首地址,如果相等的话就是就是和其中一个相等的话就是前缀或者和原来的串相等,注意一下这个函数的使用即可

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define ll long long
#include <iomanip>
const int MOD = 1E9+7;
const int maxn = 2e8+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;

char s[100][10];

int main(){
    int n;
    int a=1;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(strlen(s[i])<strlen(s[j])){
                if(strstr(s[j],s[i])==s[j]){
                    a=0;
                    break;
                }
            }
            else{
                if(strstr(s[i],s[j])==s[i]){
                    a=0;
                    break;
                }
            }
        }
    }
    if(a==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值