I - ?(>_o)!

?(>_o)! is a pseudo-object-oriented programming language. It implements the following commands:

Command Description
? :Check whether the character ‘?’ is in the program’s source code. If ‘?’ does not exist in the program’s source, the hardware will catch fire or explode.
( :It tries to match ‘)’, although mismatch of brackets does not matter at all.
> : Increase the internal accumulator.
_ :Print the program’s source code.
o :Instantiate an object of a new sub class of the generic super class. Due to the best principles of object hiding, this object cannot be accessed in any way.
) :Just matches ‘(’. It’s for patient with obsessive-compulsive disorder. However, mismatch of brackets does not matter at all.
! :Print “Hello, world!”.
Other characters : Be treated as comments rather than instruction.

However, it’s only another joke programming language. There is even no way to access the accumulator. But it’s one of easiest to finish a “Hello world” program or a quine program. A quine is a computer program which takes no input and produces a copy of its own source code as its only output. Your task is to judge whether a ?(>_o)! program is a quine.
Input

There are multiple test cases. The first line of input is an integer T indicates the number of test cases. For each test case:

There is one line of string represents the source code of a ?(>_o)! program. The program contains no more than 256 characters. The ASCII value of each character is within [32, 126].
Output

For each test case, output “Yes” if it is a quine. Otherwise, output “No”.
Sample Input

4
Hello, world!
source_code
source__code
?(>_o)!

Sample Output

Yes
Yes
No
No

Hint

The output of the four sample programs are {“Hello, world!”, “source_code”, “source__codesource__code”, “?(>_o)!Hello, world!”} respectively. Therefore the first two programs are quines, and the last two are not.

Luckily, there is a ‘?’ in the fourth program, so the hardware will not catch fire or explode during running the fourth program.






思路:照着那个表,,出现了什么就打印什么,如果打印出来的东西和原来输入的一样,那就输出Yes, else cout No
(我看了挺久的,,,,,)

//#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stdlib.h>
#include<cstring>
#include<string.h>
#include<string>
#include<math.h>
using namespace std ;
typedef long long ll;
#define MAXN 260
#define INF 0x3f3f3f3f
#define MA (Qnode *)maoc(sizeof(Qnode));

int main()
{
    int t;
    cin >> t;
    getchar();
    while(t--)
    {
        char ch[MAXN], sh[MAXN*MAXN];//这里一定要MAXN*MAXN, 因为可以全是‘_’这个恶心的东西。。。
        memset(ch, '\0', sizeof(ch));
         memset(sh, '\0', sizeof(sh));
        gets(ch);
        int len = strlen(ch);
        int x=0;
        for(int i=0; i<len; ++i)
        {
            if(ch[i] == '_')
                strcat(sh, ch);
            if(ch[i] == '!')
            {
                strcat(sh, "Hello, world!");
            }
        }
//        puts(sh);
//        puts(ch);
        if(strcmp(sh, ch) == 0)
            cout << "Yes" << '\n';
        else
            cout << "No" << '\n';

    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值