跳到正文

剪贴板

剪贴板 30tevogp

原文
剪贴板信息

剪贴板信息

收录
更新

LAZD (BETA)3000.02

C++
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

map<string, int> m;//int 类型数据库
map<string, string> s; //string类型数据库

struct sic{
	char j;
	int area;
	double time;
}lisi[10001];

int main()
{
	system("color 7E");
	cout << "请输入用户名:";
	string user_name;
	cin >> user_name;
	cout << "亲爱的" << user_name << "用户,欢迎使用LAZD (BETA)3000.02!\n";
	Beep(261.6, 100);
	Beep(293.6, 100);
	Beep(329.6, 100);
	Beep(349.2, 100);
	Beep(392, 100);
	Beep(440, 100);
	Beep(493.8, 100);
	Beep(261.6*2, 100);
	Sleep(1000);
	system("cls");
	cout << "正在进入编辑器...";
	Sleep(3000);
	system("cls");
	cout << "---------- [LAZD (BETA)3000.02] ----------\n";
	cout << "您可以输入help打开语言指引向导\n";
	for (int i = 1; ; i++)
	{
		cout << i << "> ";
		string op;
		cin >> op;
		if (op=="def")
		{
			string defop;
			cin >> defop;
			if (defop=="int")
			{
				string iname;
				int idata;
				cin >> iname >> idata;
				if (m.count(iname)!=0) cout << "CE: " << iname << " 此变量名已被定义!\n";
				else m[iname]=idata;
				//cout << iname << "=" << idata << endl;
			}
			else if (defop=="string")
			{
				string iname;
				string idata;
				cin >> iname >> idata;
				if (s.count(iname)!=0) cout << "CE: " << iname << " 此变量名已被定义!\n";
				else s[iname]=idata;
				//cout << iname << "=" << idata << endl;
			}
		}
		else if (op=="lucky")
		{
			srand(time(0));
			int a=rand()%100+1;
			cout << "亲爱的用户" << user_name << ",您的幸运数字为:" << a << "!\n";
		}
		else if (op=="square")
		{
			int n, m;
			char c;
			cin >> n >> m >> c;
			for (int i = 1; i <= n; i++)
			{
				for (int j = 1; j <= m; j++)
				{
					cout << c;
				}
				cout << endl;
			}
		}
		else if (op=="sound")
		{
			char j;
			int area;
			double time;
			cin >> j >> area >> time;
			if (j=='C') Beep(261.6*area, time*1000);
			if (j=='D') Beep(293.6*area, time*1000);
			if (j=='E') Beep(329.6*area, time*1000);
			if (j=='F') Beep(349.2*area, time*1000);
			if (j=='G') Beep(392*area, time*1000);
			if (j=='A') Beep(440*area, time*1000);
			if (j=='B') Beep(493.8*area, time*1000);
		}
		else if (op=="music")
		{
			int n;
			cin >> n;
			for (int i = 1; i <= n; i++)
			{
				cin >> lisi[i].j >> lisi[i].area >> lisi[i].time;
			}
			for (int i = 1; i <= n; i++)
			{
				if (lisi[i].j=='C') Beep(261.6*lisi[i].area, lisi[i].time*1000);
				if (lisi[i].j=='D') Beep(293.6*lisi[i].area, lisi[i].time*1000);
				if (lisi[i].j=='E') Beep(329.6*lisi[i].area, lisi[i].time*1000);
				if (lisi[i].j=='F') Beep(349.2*lisi[i].area, lisi[i].time*1000);
				if (lisi[i].j=='G') Beep(392*lisi[i].area, lisi[i].time*1000);
				if (lisi[i].j=='A') Beep(440*lisi[i].area, lisi[i].time*1000);
				if (lisi[i].j=='B') Beep(493.8*lisi[i].area, lisi[i].time*1000);
			}
		}
		else if (op=="play")
		{
			string music;
			cin >> music;
			if (music=="happy")
			{
				Beep(329.6, 500);
				Beep(329.6, 500);
				Beep(349.2, 500);
				Beep(392, 500);
				Beep(392, 500);
				Beep(349.2, 500);
				Beep(329.6, 500);
				Beep(293.6, 500);
				Beep(261.6, 500);
				Beep(261.6, 500);
				Beep(293.6, 500);
				Beep(329.6, 500);
				Beep(329.6, 750);
				Beep(293.6, 250);
				Beep(293.6, 1000);
				Beep(329.6, 500);
				Beep(329.6, 500);
				Beep(349.2, 500);
				Beep(392, 500);
				Beep(392, 500);
				Beep(349.2, 500);
				Beep(329.6, 500);
				Beep(293.6, 500);
				Beep(261.6, 500);
				Beep(261.6, 500);
				Beep(293.6, 500);
				Beep(329.6, 500);
				Beep(293.6, 750);
				Beep(261.6, 250);
				Beep(261.6, 1000);
			}
		}
		else if (op=="set")
		{
			string now;
			cin >> now;
			string en;
			cin >> en;
			if (en=="equal:int")
			{
				map<string, int>::iterator it=m.find(now);
				if (it!=m.end())
				{
					int x;
					cin >> x;
					m[now]=x;
				}
				else cout << "CE: " << now << " 此变量未定义!\n";
			}
			if (en=="equal:string")
			{
				map<string, string>::iterator it=s.find(now);
				if (it!=s.end())
				{
					string x;
					cin >> x;
					s[now]=x;
				}
				else cout << "CE: " << now << " 此变量未定义!\n";
			}
			if (en=="+=")
			{
				map<string, int>::iterator it=m.find(now);
				if (it!=m.end())
				{
					int x;
					cin >> x;
					m[now]+=x;
				}
				else cout << "CE: " << now << " 此变量未定义!\n";
			}
			if (en=="-=")
			{
				map<string, int>::iterator it=m.find(now);
				if (it!=m.end())
				{
					int x;
					cin >> x;
					m[now]-=x;
				}
				else cout << "CE: " << now << " 此变量未定义!\n";
			}
			if (en=="*=")
			{
				map<string, int>::iterator it=m.find(now);
				if (it!=m.end())
				{
					int x;
					cin >> x;
					m[now]*=x;
				}
				else cout << "CE: " << now << " 此变量未定义!\n";
			}
			if (en=="/=")
			{
				map<string, int>::iterator it=m.find(now);
				if (it!=m.end())
				{
					int x;
					cin >> x;
					if (x==0) cout << "CE: 除数不能为0!\n";
					else m[now]/=x;
				}
				else cout << "CE: " << now << " 此变量未定义!\n";
			}
			else cout << "CE: 此操作未定义!\n";
		}
		else if (op=="print")
		{
			string pop;
			cin >> pop;
			if (pop==":int")
			{
				string print_name;
				cin >> print_name;
				map<string, int>::iterator it=m.find(print_name);
				if (it!=m.end()) cout << m[print_name] << endl;
				else cout << "CE: " << print_name << " 此变量未定义!\n";
			}
			else if (pop==":string")
			{
				string print_name;
				cin >> print_name;
				map<string, string>::iterator it=s.find(print_name);
				if (it!=s.end()) cout << s[print_name] << endl;
				else cout << "CE: " << print_name << " 此变量未定义!\n";
			}
			else cout << "CE:" << "此变量类型未找到!\n";
		}
		else if (op=="return")
		{
			int ret;
			cin >> ret;
			return ret;
		}
		else if (op=="help")
		{
			Beep(311.13, 100);
			Beep(466.16, 100);
			cout << "欢迎来到LAZD语言指引向导!\n";
			cout << "语法:\n";
			cout << "|---- def语法\n";
			cout << "|-------- def int (变量名) (int数据) 来定义一个int类型的变量,并赋值为(int)\n";
			cout << "|-------- def string (变量名) (string数据) 来定义一个string类型的变量,并赋值为(string)\n";
			cout << "|---- print语法\n";
			cout << "|-------- print :int (int变量名) 输出int类型变量(变量名)\n";
			cout << "|-------- print :string (string变量名) 输出string类型变量(变量名)\n";
			cout << "|---- set语法\n";
			cout << "|-------- set (变量名) equal:int (int数据) 来改变(变量名)的数据,赋值为(int)\n";
			cout << "|-------- set (变量名) equal:string (string数据) 来改变(变量名)的数据,赋值为(string)\n";
			cout << "|-------- set (int变量名) += (int数据) 来让(变量名)加上(int数据)\n";
			cout << "|-------- set (int变量名) -= (int数据) 来让(变量名)减去(int数据)\n";
			cout << "|-------- set (int变量名) *= (int数据) 来让(变量名)乘以(int数据)\n";
			cout << "|-------- set (int变量名) /= (int数据) 来让(变量名)除以(int数据),向下取整。注意除数不能为0\n";
			cout << "|---- sound语法\n";
			cout << "|-------- (音符缩写(大写字母)) 音高(音区) 播放秒数 来播放一个音符\n";
			cout << "|---- music语法\n";
			cout << "|-------- music (数字)来制谱\n";
			cout << "|-------- 对于每个音符:(音符缩写(大写字母)) 音高(音区) 播放秒数 来生成一个音符\n";
			cout << "|---- lucky语法\n";
			cout << "|-------- lucky 输出你的幸运数字!\n";
			cout << "|---- square语法\n";
			cout << "|-------- square n(行数) m(列数) c(填充字符) 来输出一个n*m的字符矩阵\n";
			cout << "|---- return语法\n";
			cout << "|-------- return a 结束程序,并返回a(int类型)\n";
		}
		else cout << "CE: " << op << " 此操作未定义!\n";
	}
}
//你还是来了
//去discuss/1071144看看吧