Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- //Lab 7
- char first[8][5];
- string isFirst,isFollow;
- bool isNonTerminal(char ch){
- for(int k=0;k<8;k++){
- if(first[k][0]==ch){
- return true;
- }
- }
- return false;
- }
- void find_first(char ch){
- for(int i=0;i<8;i++){
- if(first[i][0]==ch){
- if(isNonTerminal(first[i][2])){
- ch=first[i][2];
- continue;
- }else{
- isFirst+=first[i][2];
- isFollow+=first[i][2];
- }
- }
- }
- }
- void solve(){
- for(int i=0;i<8;i++)
- cin>>first[i];
- printf("\nEnter production Value to Find First:");
- char ch;
- cin>>ch;
- find_first(ch);
- cout<<ch<<" First: {"<<isFirst<<"}\n";
- }
- int main()
- {
- solve();
- return 0;
- }
- /*
- E=TX
- X=+TX
- X=#
- T=FY
- Y=*FY
- Y=#
- F=(E)
- F=I
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement