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

📄 indirect_recursion.cpp

📁 编译原理消除间接左递归。将结果存于文件中
💻 CPP
字号:
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
void main ()
{
	ifstream input_file;
	ofstream output_file;
	char a[50];
	int i=0, j=1, k=0,plength,r=1;
	bool temp=false;
	char p[50];
	for (i=0;i<50;i++) p[i]=' ';	
	for (i=0;i<50;i++) a[i]=' ';
	i=0;
	input_file.open("frist_file.txt",ios::in);
	while(!input_file.eof())  //将文法中的非终结符保存在数组p中,
	{
		temp=false;
		input_file>>a[i];
		if (a[i]>=65&&a[i]<=90)
		{
			for(int t=1;t<=r;t++)
			{	if (a[i]==p[t]) 
				temp=true;
			}
			if (temp==false)
			{
				p[j]=a[i];
				r=j;
				j++;
			}
		}
		i++;
	}
/*	j=1;   测试数组p的正确性
	while (p[j]!=' ')
	{
		j++;	
	}
	plength=j-1;
	cout <<plength;
	for (j=1;j<=plength;j++)
		cout <<p[j];*/

	





}

⌨️ 快捷键说明

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