//c++日志 //9.22 int,char,bool变量建好,find建好,暂无BUG // #include<bits/stdc++> #include<windows.h> #include<stdio.h> #include<conio.h> using namespace std; map<string,int> blw; int bls=1; struct {//变量结构体 string name; bool h=0; int lx=1; long long int iz; char cz; bool bz; signed bllz() {//find输出值 if(lx==1) { return iz; } else if(lx==2) { return cz; } else if(lx==3) { return bz; } } string bllx() {//find输出类型 if(lx==1) { return "int"; } else if(lx==2) { return "char"; } else if(lx==3) { return "bool"; } } } blz[100]; int main() { system("TITLE c++"); while(1) { cout<<">>>"; string s; cin>>s; if(s=="int") {//变量int cout<<"name>>>"; cin>>s; if(blw[s]==0) { blw[s]=bls; blz[bls].lx=1; blz[bls].name=s; blz[bls].iz=0; blz[bls].h=1; bls++; system("cls"); cout<<"int "<<s<<"\n"; system("pause"); } else { cout<<"[Error] Variable "<<s<<" exists\n";//报错 system("pause"); } } else if(s=="char") {//变量char cout<<"name>>>"; cin>>s; if(blw[s]==0) { blw[s]=bls; blz[bls].lx=2; blz[bls].name=s; blz[bls].cz=0; blz[bls].h=1; bls++; system("cls"); cout<<"char "<<s<<"\n"; system("pause"); } else { cout<<"[Error] Variable "<<s<<" exists\n";//报错 system("pause"); } } else if(s=="bool") {//变量bool cout<<"name>>>"; cin>>s; if(blw[s]==0) { blw[s]=bls; blz[bls].lx=3; blz[bls].name=s; blz[bls].bz=0; blz[bls].h=1; bls++; system("cls"); cout<<"bool "<<s<<"\n"; system("pause"); } else { cout<<"[Error] Variable "<<s<<" exists\n";//报错 system("pause"); } } else if(s=="find") { //find cout<<"name>>"; cin>>s; system("cls"); if(blz[blw[s]].h) { cout<<"类型:"<<blz[blw[s]].bllx(); cout<<"\n名称:"<<blz[blw[s]].name; cout<<"\n值:"<<blz[blw[s]].bllz(); cout<<"\n位置:"<<blw[s]<<"\n"; } else { cout<<"[Error] Variable \""<<s<<"\" doesn't exists\n";//报错 } system("pause"); system("cls"); }/// else if(s=="oper") { //运算 cout<<"name>>>"; cin>>s; if(blz[blw[s]].h) { char ysf; cin>>ysf; int sz; bool l=0; if(ysf== '+')l=1; if(ysf== '-')l=1; if(ysf== '*')l=1; if(ysf== '/')l=1; if(ysf== '%')l=1; if(ysf== '=')l=1; if(ysf== '^')l=1; if(ysf== '~')l=1; if(ysf== '&')l=1; if(ysf== '|')l=1; if(l){ cin>>sz; } else{ cout<<"[Error] Variable \""<<s<<"\" doesn't exists\n";//报错 }/// } else { cout<<"[Error] Variable \""<<s<<"\" doesn't exists\n";//报错 } } else { //结束点 cout<<"[Error] There is no such word\n";//报错 system("pause"); } system("cls"); } return 0; }