// ConsoleApplication14.cpp:
//
#include“stdafx.h“
#include<iostream>
#include<fstream>
#include<string>
#include<stdlib.h>
#include<iomanip>
#include<windows.h>
#include<cmath>
using namespace std;
#define MAXSIZE 0xffff
int ip = 0;
int N = 0;
int n = 0;//stack number
bool flag=1;
int top = 0;//变量存储
struct node {
node *index;
node *bro=NULL;
node *child=NULL;
int id;
string text;
bool hasval=true;
double val;
}S, A, B, C, D, E, F, G, H, I, J,*sheet,*p,*start;
struct variable{
string name;
double val;
}var[20];
int find_var(string a){
for (int i = 0; i <top; i++)
if (var[i].name == a)
return i;
return -1;
}
template<class type>
class my_stack
{
int top;
type* my_s;
int maxsize;
public:
my_stack():top(-1), maxsize(MAXSIZE)
{
my_s = new type[maxsize];
if (my_s == NULL)
{
cerr <<“动态存储分配失败!“<< endl;
exit(1);
}
}
my_stack(int size):top(-1), maxsize(size)
{
my_s = new type[maxsize];
if (my_s == NULL)
{
cerr <<“动态存储分配失败!“<< endl;
exit(1);
}
}
~my_stack()
{
delete[] my_s;
}
//是否为空
bool Empty();
//压栈
node* Push(type tp);
//返回栈顶元素
type Top();
//返回第n个栈顶元素
type Top(int n);
//出栈
void Pop();
//栈大小
int Size();
string Show();
string show();
int Num();
};
template<class type>
bool my_stack<type>::Empty()
{
if (top ==-1){
return true;
}
else
return false;
}
template<class type>
type my_stack<type>::Top()
{
if (top !=-1)
{
return my_s[top];
}
else
{
cout <<“栈空
“;
exit(1);
}
}
template<class type>
type my_stack<type>::Top(int n)
{
if ((top - n)>-1)
{
return my_s[top - n];
}
else
{
cout <<“栈空
“;
exit(1);
}
}
node* my_stack<node>::Push(node tp)
{
node *temp = new node;
*temp = tp;
temp->index = temp;
n++;
if (top + 1<maxsize)
{
my_s[++top]=*temp;
}
else
{
cout <<“栈满
“;
exit(1);
}
return temp;
}
template<class type>
int my_stack<type>::Num(){
return top;
}
template<class type>
void my_stack<type>::Pop()
{
if (top >= 0)
{
top--;
}
else
{
cout <<“栈空
“;
exit(1);
}
}
template<class type>
int my_stack<type>::Size()
{
return top + 1;
}
template<class type>
string my_stack<type>::Show(){
string s;
for (int i = 0; i <= top; i++)
s += my_s[i].text;
return s;
}
string my_stack<node>::show(){
string s;
for (int i = 0; i <= top; i++)
s+=(my_s[i].index->text)+““;
return s;
}
void S_P(node *sheet, node *a, my_stack<node>&stack){
cout <<“pop(S),“;
node t10 = sheet[10];
node t9 = sheet[9];
switch (a[ip].id){
case 10:
stack.Push(t9);
stack.Push(B);
stack.Push(t10);
stack.Push(A);
cout <<“push(A?B;)“;
break;
case 17:
stack.Push(t9);
stack.Push(B);
stack.Push(t10);
stack.Push(A);
cout <<“push(A?B;)“;
break;
case 21:
break;
default:
cout <<“error : NO PATTERN FOR S!
“;
flag = 0;
break;
}
}
void A_P(node *sheet, node *a, my_stack<node>&stack){
cout <<“pop(A),“;
node t9 = sheet[9];
switch (a[ip].id){
case 10:
break;
case 17:
stack.Push(A);
stack.Push(t9);
stack.Push(C);
cout <<“push(C;A)“;
break;
default:
cout <<“error : NO PATTERN FOR A!
“;
flag = 0;
break;
}
}
void B_P(node *sheet, node *a, my_stack<node>&stack){
cout <<“pop(B),“;
switch (a[ip].id){
case 0:
stack.Push(E);
stack.Push(D);
cout <<“push(DE)“;
break;
case 1:
stack.Push(E);
stack.Push(D);
cout <<“push(DE)“;
break;
case 2:
stack.Push(E);
stack.Push(D);
cout <<“push(DE)“;
break;
case 3:
stack.Push(E);
stack.Push(D);
cout <<“push(DE)“;
break;
case 4:
stack.Push(E);
stack.Push(D);
cout <<“push(DE)“;
break;
case 5:
stack.Push(E);
stack.Push(D);
cout <<“push(DE)“;
break;
case 6:
stack.Push(E);
stack.Push(D);
cout <<“push(DE)“;
break;
case 7:
stack.Push(E);
stack.Push(D);
cout <<“push(DE)“;
break;
case 12:
stack.Push(E);
stack.Push(D);
cout <<“push(DE)“;
break;
case 17:
stack.Push(E);
stack.Push(D);
cout <<“push(DE)“;
break;
case 18:
stack.Push(E);
stack.Push(D);
cout <<“push(DE)“;
break;
case 19:
stack.Push(E);
stack.Push(D);
cout <<“push(DE)“;
break;
case 20:
stack.Push(E);
stack.Push(D);
cout <<“push(DE)“;
break;
default:
cout <<“error : NO PATTERN FOR B!
“;
flag = 0;
break;
}
}
void C_P(node *sheet, node *a, my_stack<node>&stack)
{
cout <<“pop(C),“;
node t17 = sheet[17];
node t15 = sheet[15];
switch (a[ip].id){
case 17:
stack.Push(B);
stack.Push(t15);
stack.Push(t17);
cout <<“push(var=B)“;
break;
default:
cout <<“error : NO PATTERN FOR C!
“;
flag = 0;
break;
}
}
void D_P(node *sheet, node *a, my_stack<node>&stack){
cout <<“pop(D),“;
switch (a[ip].id){
case 0:
stack.Push(G);
stack.Push(F);
cout <<“push(FG)“;
break;
case 1:
stack.Push(G);
stack.Push(F);
cout <<“push(FG)“;
break;
case 2:
stack.Push(G);
stack.Push(F);
cout <<“push(FG)“;
break;
case 3:
stack.Push(G);
stack.Push(F);
cout <<“push(FG)“;
break;
case 4:
stack.Push(G);
stack.Push(F);
cout <<“push(FG)“;
case 5:
stack.Push(G);
stack.Push(F);
cout <<“push(FG)“;
break;
case 6:
stack.Push(G);
stack.Push(F);
cout <<“push(FG)“;
break;
case 7:
stack.Push(G);
stack.Push(F);
cout <<“push(FG)“;
break;
case 12:
stack.Push(G);
stack.Push(F);
cout <<“push(FG)“;
break;
case 17:
stack.Push(G);
stack.Push(F);
cout <<“push(FG)“;
break;
case 18:
stack.Push(G);
stack.Push(F);
cout <<“push(FG)“;
break;
case 19:
stack.Push(G);
stack.Push(F);
cout <<“push(FG)“;
case 20:
stack.Push(G);
stack.Push(F);
break;
cout <<“push(FG)“;
break;
break;
default:
flag = 0;
cout <<“error : NO PATTERN FOR D!
“;
break;
}
}
void E_P(node *sheet, node *a, my_stack<node>&stack){
cout <<“pop(E),“;
node t11 = sheet[11], t12 = sheet[12];
switch (a[ip].id){
case 8:
break;
case 9:
break;
case 11:
stack.Push(E);
stack.Push(D);
stack.Push(sheet[11]);
cout <<“push(+DE)“;
break;
case 12:
stack.Push(E);
stack.Push(D);
stack.Push(sheet[12]);
cout <<“push(-DE)“;
break;
default:
flag = 0;
cout <<“error : NO PATTERN FOR E!
“;
break;
}
}
void F_P(node *sheet, node *a, my_stack<node>&stack){
cout <<“pop(F),“;
switch (a[ip].id){
case 0:
stack.Push(sheet[8]);
stack.Push(H);
stack.Push(sheet[7]);
stack.Push(sheet[0]);
cout <<“push(sin(H))“;
break;
case 1:
stack.Push(sheet[8]);
stack.Push(H);
stack.Push(sheet[7]);
stack.Push(sheet[1]);
cout <<“push(cos(H))“;
break;
case 2:
stack.Push(sheet[8]);
stack.Push(H);
stack.Push(sheet[7]);
stack.Push(sheet[2]);
cout <<“push(tg(H))“;
break;
case 3:
stack.Push(sheet[8]);
stack.Push(H);
stack.Push(sheet[7]);
stack.Push(sheet[3]);
cout <<“push(ctg(H))“;
break;
case 4:
stack.Push(sheet[8]);
stack.Push(H);
stack.Push(sheet[7]);
stack.Push(sheet[4]);
cout <<“push(log(H))“;
break;
case 5:
stack.Push(sheet[8]);
stack.Push(H);
stack.Push(sheet[7]);
stack.Push(sheet[5]);
cout <<“push(lg(H))“;
break;
case 6:
stack.Push(sheet[8]);
stack.Push(H);
stack.Push(sheet[7]);
stack.Push(sheet[6]);
cout <<“push(ln(H))“;
break;
case 7:
stack.Push(I);
stack.Push(H);
cout <<“push(HI)“;
break;
case 12:
stack.Push(I);
stack.Push(H);
cout <<“push(HI)“;
break;
case 17:
stack.Push(I);
stack.Push(H);
cout <<“push(HI)“;
break;
case 18:
stack.Push(I);
stack.Push(H);
cout <<“push(HI)“;
break;
case 19:
stack.Push(I);
stack.Push(H);
cout <<“push(HI)“;
break;
case 20:
stack.Push(I);
stack.Push(H);
cout <<“push(HI)“;
break;
default:
cout <<“error : NO PATTERN FOR F!
“;
flag = 0;
break;
}
}
void G_P(node *sheet, node *a, my_stack<node>&stack){
cout <<“pop(G),“;
switch (a[ip].id){
case 8:
break;
case 9:
break;
case 11:
break;
case 12:
break;
case 13:
stack.Push(G);
stack.Push(F);
stack.Push(sheet[13]);
cout <<“push(*FG)“;
break;
case 14:
stack.Push(G);
stack.Push(F);
stack.Push(sheet[14]);
cout <<“push(/FG)“;
break;
default:
cout <<“error : NO PATTERN FOR G!
“;
flag = 0;
break;
}
}
void H_P(node *sheet, node *a, my_stack<node>&stack){
cout <<“pop(H),“;
switch (a[ip].id){
case 7:
stack.Push(sheet[8]);
stack.Push(B);
stack.Push(sheet[7]);
cout <<“push((B))“;
break;
case 12:
stack.Push(H);
stack.Push(sheet[12]);
cout <<“push(-H)“;
break;
case 17:
小说推荐
- 神医姐姐太难撩了怎么办
- 小白:在线求助,在医院她是我的顶头上司,回到家她是我的合租室友,不爱化妆却天生丽质,鄙视男人却对我格外温柔,别人眼中的高冷女神,在我面前是温柔姐姐,请问有这样一位女朋友,我需要注意什么 网友A:卧槽!撒狗粮的都该死 网友B:你该醒醒了 网友C:我尿黄,我来哧醒他 网友D:大白天的就开始做梦,这是病,
- 都市一颗地黄丸连载
- 最新章:第57章都是套路
- 怎么办,姐姐直播了我的超能力
- 【飞卢小说网独家签约小说:怎么办,姐姐直播了我的超能力】历经千难万险,江明辰终于从轮回空间中归来!原本打算再继续他平静悠闲的生活,却没想,先是他在轮回空间里获得的超凡能力被他老姐给直播了出去,紧接着他又被在全网上爆出了同顶流女星的绯闻。江明辰的心态直接崩了。飞卢小说网提醒您:本小说及人物纯属虚构,如
- 玄奇我在聆听连载
- 最新章:第六十五节 你不是还有个召唤技能吗?
- 手办活过来了怎么办
- 吕建是个手办制作者。正当他的第一件手办妖刀姬完美收工,准备挂到某宝上卖出一个好价钱的时候…一柄赤红色的大刀突然架在了他的脖子之上“听说,你要卖了我
- 玄奇鼻炎又犯了连载
- 最新章:第三十九章 我是吾妻妖刀姬
- 被大小姐收养了怎么办
- 绑架、包养和逼婚,乡野出身的方野刚出门闯荡便遭受到弱质纤纤大小姐的三连击 父母双亡的亿万富翁女孩画了一副意中人的画像,并命人全世界寻找 于是倒霉的方野一下火车就被黑衣人掳走,莫名其妙多了一个未婚妻 奢华的别墅里每天都在上演奇葩事,方野绞尽脑汁逃出韩念念的掌爪,可是两人的孽缘却怎么也斩不断…
- 玄奇龙血布丁连载
- 最新章:第七十四章 不要变成未亡人
- 笔下小说女主来到现实怎么办
- 说出来你可能不信,只要是我笔下的女主角,总有一天都会从小说中来到现实世界,这也是我小说总是没法继续写下去的原因—李书山 PS:本书幕后黑手搞事流,感兴趣的可以耐心尝试一下 本书书友群:879748199
- 玄奇醉卧笑伊人连载
- 最新章:完本感言
- 把女上司写进小说被发现了怎么办
- 我叫江成,在电子厂流水线当线长。我爱好文学,喜欢阅读,梦想是当一名作家,于是繁重的工作之余,在小说网站试着写小说。目前,我刚完结了一本老书,正在写一本新小说的开头。这是一本都市类型的YY小说,第一女主是根据我们厂的美女经理为原型进行的设定。这一切都没有问题。但是…我给编辑发稿子试读的时候,不小心,把
- 玄奇星河望鱼连载
- 最新章:29 原来你觉得我漂亮
- 我女朋友是越剧小生怎么办?
- 曲亦良接手了一个濒临倒闭的不正经黄梅剧团,欠下巨额债务待还。还有一个保持了8年,先异地后一处的地下恋女朋友,是本工越剧小生。最尴尬的事是:女朋友爷们起来,比他强多了,又温柔又多情,还比他会撩。这特么谁受得了?他含泪作出一个艰难决定:帮女朋友改行反串,不唱小生改唱花旦,并让她一直唱下去。对曲亦良来说,
- 玄奇不救李郎女驸马连载
- 最新章:第39章、希望你不要给我这个机会
- 末日要来了怎么办
- 三年后,末日就要来了,该咋办 重生后的慕白略一思索 要不,我们让几年后的灵气提前复苏下 emmm…正好我知道末日世界的坐标,要不引领下第四天灾的风潮 慕白的笑容逐渐变态起来 本书又名《我真的不是幕后黑手《对抗末日的一万种办法《我就是个酋长。
- 玄奇荣灯连载
- 最新章:第六十七章 征讨部落
- 世界要崩怎么办
- 这是一个看脸的世界,没有颜值的人,将一无所有,包括生命 而这个世界的崩塌,已经进入了倒计时。
- 次元一垛墙头草连载
- 最新章:第一百零二章 通道
《那么修女小姐要怎么办呢》情节跌宕起伏、扣人心弦,是一本情节与文笔俱佳的玄奇,千千小说网转载收集那么修女小姐要怎么办呢最新章节。