Simulation Sw Exercise Write Three C Programs Simulate Following Automaton B Q37298473

Simulation+SW Exercise: Write three C++ programs to simulate each of the following automaton a,b
please write C++ program to simulate any two of the followingautomatonSimulation+SW Exercise: Write three C++ programs to simulate each of the following automaton a,b Show transcribed image text Simulation+SW Exercise: Write three C++ programs to simulate each of the following automaton a,b


Answer


//C++ program

#include<iostream>
using namespace std;

bool automata1(string str){
   int state=0;
   for(int i=0;i<str.length();i++){
       char ch = str[i];
       if(state==0 &&ch==’a’)state = 1;
       else if(state==0 &&ch==’b’)state = 0;
       else if(state==1 &&ch==’a’)state = 0;
       else if(state==1 &&ch==’b’)state = 1;
   }
   if(state==0)return true;
  

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.