91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

語言為C++,使用了set,map容器,輸入格式:S -> Aa | g | e,支持多‘|’ 符號,采用文件輸入

資源截圖

代碼片段和文件信息

#include
#include
#include
#include
#include
#include
#include
#include?
#define?filename?“in2.txt“

using?namespace?std;

ifstream?input(filename);
map?>first;?//first集合
map?>follow;?//follow集合
map?>first_temp;
map?>follow_temp;
map?>string_temp;
settable;?//終結符號
setno_end;?//非終結符
string?s[10][10];?//分析表
mapxlab;
mapylab;

set?split(string&?strconst?char*?c)??//按|分割輸入的產生式
{
????char?*cstr?*p;
????set?res;
????cstr?=?new?char[str.size()+1];
????strcpy(cstrstr.c_str());
????p?=?strtok(cstrc);
????while(p!=NULL)
????{
????????res.insert(p);
????????p?=?strtok(NULLc);
????}
????return?res;
}

bool?isEnd(char?a)???//判斷是否是終結符
{
????if(a>=‘A‘?&&?a<=‘Z‘)
????????return?false;
????else
????????return?true;
}

/*void?EndAndNoEnd()
{
????string?temp;
????string?temp1;
????set?temp2;
????map?all_temp;
????unsigned?int?start?=?0;
????while(getline(inputtemp))
????{
????????cout<????????all_temp[temp[0]]?=?temp;
????}
????map::iterator?iter1=all_temp.begin();
????int?all_size?=?all_temp.size();
????for(int?i?=?0;i?????{
????????temp?=?iter1->second;
????????no_end.insert(temp[0]);
????????int?len?=?temp.length();
????????temp1?=?temp.substr(5len?-?5);
????????temp2?=?split(temp1“?|?“);
????????set::iterator?ite1?=?temp2.begin();
????????set::iterator?ite2?=?temp2.end();
????????//if(first.find(temp[0])==first.end())
????????for(;ite1!=ite2;ite1++)
????????{
????????????int?maxt?=?(*ite1).length();
????????????for(int?j?=?;j????????????{
????????????????if(isEnd((*ite1)[j]))
????????????????????table.insert((*ite1)[j]);
????????????}
????????}
????}
}*/

void?First()
{
????string?temp;
????string?temp1;
????set?temp2;
????map?all_temp;???//輸入的所有產生式
????unsigned?int?start?=?0;
????while(getline(inputtemp))
????{
????????cout<????????all_temp[temp[0]]?=?temp;
????}
????map::iterator?iter1=all_temp.begin();
????int?all_size?=?all_temp.size();
????for(int?i?=?0;i?????{
????????temp?=?iter1->second;
????????int?len?=?temp.length();
????????temp1?=?temp.substr(5len?-?5);
????????temp2?=?split(temp1“?|?“);
????????set::iterator?ite1?=?temp2.begin();
????????set::iterator?ite2?=?temp2.end();
????????//if(first.find(temp[0])==first.end())
????????for(;ite1!=ite2;ite1++)
????????{
????????????//cout<<*ite1<????????????start?=?0;
????????????if(isEnd((*ite1)[start]))
????????????????first[temp[0]].insert((*ite1)[start]);
????????????else
????????????{
????????????????first_temp[temp[start]].insert((*ite1)[start]);
????????????????while(start+1<(*ite1).length())
??????????????

評論

共有 條評論