xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 14KB
    文件類型: .cpp
    金幣: 1
    下載: 1 次
    發(fā)布日期: 2021-07-11
  • 語言: C/C++
  • 標(biāo)簽: first集??follow??LL1文法??

資源簡介

語言為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;?//終結(jié)符號
setno_end;?//非終結(jié)符
string?s[10][10];?//分析表
mapxlab;
mapylab;

set?split(string&?strconst?char*?c)??//按|分割輸入的產(chǎn)生式
{
????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)???//判斷是否是終結(jié)符
{
????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;???//輸入的所有產(chǎn)生式
????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())
??????????????

評論

共有 條評論

相關(guān)資源