#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
void deadfish(string com)
{
long long acc = 0;
for(int i=0;i<com.length();i++)
{
switch (com[i])
{
case 'i':
acc++;
break;
case 'd':
acc--;
break;
case 's':
acc = acc * acc;
break;
case 'o':
cout << acc << " ";
break;
case 'w':
cout << char(acc);
break;
default:
break;
}
}
}
int main()
{
printf("Deadfish interpreter by PSTF\n");
string a;
while(1)
{
cout << ">>> ";
cin >> a;
if(a == "exit")
{
cout << "Thank you for using!";
return 0;
}
else
{
deadfish(a);
cout << "\n\n";
}
}
}
注:此处多了一个w的命令,表示将累加器输出为字符。
关于Deadfish:这个网站上有介绍