标题:代码wrong answer UVa 10340
取消只看楼主
ZZCaleb
Rank: 1
等 级:新手上路
帖 子:5
专家分:3
注 册:2018-4-12
结帖率:0
已结贴  问题点数:20 回复次数:0 
代码wrong answer UVa 10340
这个代码总是提交时wrong answer,各位帮忙看看,谢谢啦

UVa 10340  https://

#include<stdio.h>
#include<string.h>

const int maxn = 100010;
char s[maxn],t[maxn];
int main()
{
    //freopen("3-9.txt","r",stdin);
    while(scanf("%s%s",s,t) != EOF)
    {
    int sl = strlen(s),tl = strlen(t),k = 1;
    if(sl >= tl)
    {
        if(!strcmp(s,t))
        printf("Yes\n");
        else printf("No\n");
    }
    else
    {
        for(int i = 0; i < sl; i++)
        {
            if(strchr(t,s[i])) continue;
            k = 0;
            break;
        }
        if(k == 0)  printf("No\n");
        else
        {
            int sum = 0, m = 0, n = 0;
            for(int i = n; i < sl; i++)
                for(int j = m; j < tl; j++)
                {
                    if(s[i] == t[j])
                    {
                        sum++;
                        m = j;
                        n = i;
                        break;
                    }
                }
            if(sum == sl)
            printf("Yes\n");
            else   printf("No\n");
        }
    }
    }   
    return 0;
 }
搜索更多相关主题的帖子: 代码 wrong answer int printf 
2018-04-12 09:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-485997-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.716620 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved