Advertisement
Rakibul_Ahasan

Untitled

Mar 14th, 2021
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. //Lab 7
  4. char first[8][5];
  5.  
  6. string isFirst,isFollow;
  7.  
  8. bool isNonTerminal(char ch){
  9. for(int k=0;k<8;k++){
  10. if(first[k][0]==ch){
  11. return true;
  12. }
  13. }
  14. return false;
  15. }
  16.  
  17. void find_first(char ch){
  18. for(int i=0;i<8;i++){
  19. if(first[i][0]==ch){
  20. if(isNonTerminal(first[i][2])){
  21. ch=first[i][2];
  22. continue;
  23. }else{
  24. isFirst+=first[i][2];
  25. isFollow+=first[i][2];
  26. }
  27. }
  28. }
  29. }
  30.  
  31. void solve(){
  32.  
  33.  
  34.  
  35. for(int i=0;i<8;i++)
  36. cin>>first[i];
  37.  
  38. printf("\nEnter production Value to Find First:");
  39. char ch;
  40. cin>>ch;
  41. find_first(ch);
  42. cout<<ch<<" First: {"<<isFirst<<"}\n";
  43. }
  44.  
  45. int main()
  46. {
  47. solve();
  48. return 0;
  49. }
  50.  
  51. /*
  52. E=TX
  53. X=+TX
  54. X=#
  55. T=FY
  56. Y=*FY
  57. Y=#
  58. F=(E)
  59. F=I
  60. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement