, , , , , . .

 

 

!

 

:

:

 

 

 

?

StudentHelp, , MS Word. , , antiplagiat.ru, etxt.ru advego.ru. StudentHelp , Word .


:


:

: . : 18.09.2012. : 2011. : 2. antiplagiat.ru: < 30%

():


1. .

:
1., LL(1), , ;
2. .1 LL(1)- ;
3. LL(1)- . , .




2. :
S::=caA
A::=(L)|L
L::=e,L|e

S -


3. LL(1)-:
1)S::=caA
2)A::=(L)
3)A::=L
4)L::=eZ
5)Z::=,L
6)Z::=L

4. :

c a ( ) e , $
S caS, 1
A (L), 2 L, 3
L eZ, 4
Z L, 6 ,L, 5
c
a
(
)
e
,
$


5. :

# include <iostream>
# include <fstream>
# include <string>
using namespace std;
struct Symb
{
char s1;
char s2;
string str;
char out;
struct Symb *next;
};
void add_to_list (struct Symb* &head, struct Symb t)
{
struct Symb* ptr=new struct Symb;
*(ptr)=t;
if (head==NULL)
ptr->next=NULL;
else
ptr->next=head;
head=ptr;
}
void del_list (struct Symb* &head)
{
struct Symb* ptr;
while (head!=NULL)
{
if (head->next!=NULL)
{
ptr=head;
head=head->next;
delete ptr;
}
else
{
delete head;
head=NULL;
}
}
}
void read_file(struct Symb* &head)
{
ifstream inFile ("table.txt", ios::in);
char s; struct Symb t; string st;
inFile>>s;
while (!inFile.eof())
{
t.s1=s; inFile>>s;
t.s2=s; inFile>>st;
t.str=st; inFile>>s;
if (t.str==""||t.str=="")
{
add_to_list(head,t);
continue;
}
t.out=s;
inFile>>s;
add_to_list(head,t);
}
inFile.close();
}
bool search (struct Symb* head,char inis,char sts,string& str,char& outs)
{
struct Symb* ptr=head;
while (ptr!=NULL)
{
if (inis==ptr->s1)
if (sts==ptr->s2)
{
str=ptr->str;
outs=ptr->out;
return true;
}
ptr=ptr->next;
}
return false;
}
void pop_stack(string &stack,int &top)
{
if (top>0)
{
stack.erase(top,1);
top--;
}
}
void replace_str(string &str)
{
string str1="";
for (int i=str.length()-1; i>=0; i--)
str1+=str[i];
str=str1;
}
void push_stack(string &stack,int &top,string str)
{
replace_str(str);
stack+=str;
top+=str.length();
}
bool LL (struct Symb* head,string inistr,string &outstr)
{
string stack,str; int top=1,curs=0;
stack="$S";
char outs;
while (inistr[curs]!='\0')
{
if(search(head,inistr[curs],stack[top],str,outs))
{
switch (str[0])
{
case '':
{
pop_stack(stack,top);
curs++;
break;
}
case '':
return true;
default:
{
pop_stack(stack,top);
if(str!="")
push_stack(stack,top,str);
outstr+=outs;
break;
}
}
}
else
return false;
}
return true;
}
int main()
{
struct Symb* head=NULL;
string inistr,outstr="";
cout<<"Enter string: ";
cin>>inistr;
read_file(head);
if(LL(head,inistr,outstr))
{
cout<<"The string is allowed"<<endl;
cout<<"Resulting string: ";
cout<<outstr<<endl;
}
else
cout<<"The string is unallowed"<<endl;

del_list(head);
return 0;
..................



90% antiplagiat.ru, etxt.ru advego.ru




* . , .