题目链接:ZOJ 3775 ?(>_o)!(模拟)
模拟。
这题就是个大忽悠,定义一堆符号其实只有两个符号有用,"_"和“!”,有一个下划线表示把输入输出一次,当然有两个就输出两次,感叹号表示输出"Hello, world!"。
有一点需要注意的是输入字符串可能是有空格的,所以cin和scanf都不好使了,得用getline或者gets,不过这题显然用string比char[]容易得多。
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;
string _in, _out;
int T;
int main()
{
cin >> T;
getchar();
while(T--)
{
getline(cin, _in);
_out = "";
int len = _in.length();
for(int i = 0; i < len; i++)
{
if(_in[i] == '_')
_out += _in;
else if(_in[i] == '!')
_out += "Hello, world!";
}
if(_in == _out)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}