zoj 3775

题目看了半天没有看明白,后来查了一下。主要是!和_两个符号有用。!新字符串中输出一个hello, world!(直接从页面上复制过去好了,中间有个空格)。另一个符号是将输入的字符重复一遍。题意最后是比较新字符串和输入的字符串是否一样。

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
using namespace std;

int main()
{
    int cas,i,j,len,temp;
    char st[]="Hello, world!";
    char s[1024],ss[100024];
    scanf("%d",&cas);
    getchar();
    while(cas--)
    {
        gets(s);
        len=strlen(s);
        temp=0;
        memset(ss,0,sizeof(ss));
        for(i=0;i<len;i++)
        {
            if(s[i]=='_')
            {
                for(j=0;j<len;j++)
                    ss[temp++]=s[j];
            }
            else if(s[i]=='!')
            {
                for(j=0;j<strlen(st);j++)
                ss[temp++]=st[j];
            }
        }
        ss[temp]='';
        if(strcmp(ss,s)==0) printf("Yes
");
        else printf("No
");
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/

原文地址:https://www.cnblogs.com/xryz/p/4848070.html