假条,今天要写编译原理,来不及更新啦

小说:那么修女小姐要怎么办呢在线阅读  作者:神子晶
// 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:
小说推荐
《那么修女小姐要怎么办呢》情节跌宕起伏、扣人心弦,是一本情节与文笔俱佳的玄奇,千千小说网转载收集那么修女小姐要怎么办呢最新章节。
返回首页返回目录