⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 new.cpp

📁 递归子程序法:对应每个非终结符语法单元编一个独立的处理过程(或子程序)。语法分析从读入第一个单词开始
💻 CPP
字号:
#include<stdio.h>
#include<iostream.h>
#include<malloc.h>
//char *p;/*存放非终结符*/
//char *q;/*存放终结符*/
//int GetcharNum()//获得输入字符个数
//{
//	//int i=0;
//	char ch;  
//	char *tempt=new char[100];
//	while((ch=getchar())!='\n')
//	{
//		++i;
//	}
//	return i;
//}
/*
char *tempt;
int Char()
{
	int i=0;
	char ch;  
	tempt=new char[100];
	while((ch=getchar())!='\n')
	{
		if(ch=='-')
		{
			ch=getchar();
			if(ch=='>')
			{
				ch=getchar();
			}
		}
		tempt[i]=ch;
		i++;
	}
	return i;
}
*/
#define MAX 100;
typedef struct
{
	char *base;
	char *top;
	int stacksize;
}stack;
void create(stack &s)
{
	s.base=s.top=(char*)malloc(sizeof(char));
	s.stacksize=MAX;
}
void push(stack &s,char e)
{
	*s.top++=e;
}
void pop(stack &s,char &e)
{
	if(s.top==s.base)
	{
		return;
	}
	else
	{
		e=*--s.top;
	}
}
void main()
{
	stack s;
	create(s);
	char a;
	cin>>a;
	char b;
	cin>>b;
	char c;
	cin>>c;
	push(s,a);
	push(s,b);
	push(s,c);
	char d;
	pop(s,d);
	printf("%c",d);
	//int count=Char();
	//for(int i=0;i<count;i++)
	//{
	//	printf("%c",tempt[i]);
	//}
	/*
	int c=0;
	c=getchar();
	int num=0;
	while(c!=EOF)
	{
		num++;
		putchar(c);
		c=getchar();
	}
	printf("%d",num);
	//
	int i=0;
	char ch;   
	while((ch=getchar())!='\n')
	{
		i++;
	}
	printf("%d",i);
	
	//动态分配二维数组
	//scanf("%d",num);
	//char (*p)[10];
	//p=new char[num][10];
	int i,line,row;   
    char **p;   
    cout<<"请输入列数:  ";   
    cin>>line;   
    p=new char*[line];
    cout<<"请输入行数:  ";   
    cin>>row;   
    for(i=0;i<line;i++)
	{
		p[i]=new char[row];  
	}
	for(int a=0;a<line;a++)
	{
		for(int b=0;b<row;b++)
		{
			cin>>p[a][b];
		}
	}
	printf("%c",p[1][1]);
	*/
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -