Help Badly needed- FSA and ASCII stuff

W

Willing 2 Learn

Hey, I'm trying to teach myself C++ and I came across 3 problems. I
understand the concept of FSA but getting the C++ code to do it as
become an issue. Only thing is im clueless as to how to do them; these
are:

1) Devise a coding system to send CAPITAL LETTERS using the ASCII code.
Assume the lights will be ON when you start sending, and use OFF for
ZERO and ON for ONE.
2. I want to use this code to send letters to someone else by switching
the room lights on and off.
3. Write a regular expression and FSA to recognize your code.
HINT given: Consider the following issues:
* How does the received know the difference between a ONE data bit and
the ON normal state of the lights, that is, how does the receiver know
when you START and STOP sending?
* How does the receiver know how long a bit lasts, i.e., how does it
distinguish 1 from 11 from 111 ? In other words, if your code
contains a long string of zeros or ones, could the receiver lose count?
-------------------------------------------------------------------------------------------------------------------------------
2) Write a program for an FSA to recognize the Regular Expression
01(00+11)*10.
-------------------------------------------------------------------------------------------------------------------------------
3) Use C++ to implement a Non-deterministic Finite Automaton to
recognize a string consisting of the 8-bit ASCII codes for JAH

The design program should allow to easily modify the program to
recognize different regular languages, given the regular expression.
Meaning, I should be able to systematically convert ANY regular
expression into the proper tables or pattern of decisions and loops.
IN THE DOCUMENTATION of this program, I have to give the elements of
the NFA:
* alpahbet (0,1),
* states (use numbers),
* start state (use 1 as start state and 0 as the "dead" state)
* list of "accepting" states
* transition rules [number the rules] : state x input -> new state

Operation of program:

1. Input a binary digit 0 or 1, or # to stop.
2. Output the numbers of all states that are currently ON
3. For each ON state, Output all rules that apply to that state and
input,
or NONE, (in form rule number: state number x input -> new state, e.g
1: 1x0->10 ; 2: 1x0->20; 3: 1x0->30
(you need not list rules applying to the dead state)

4. Turn OFF the current states and turn ON the new states
5. Repeat until the last character # has been input
6. Output the list of ON states and the list of ACCEPTING STATES;
if ANY ACCEPTING state is ON, output STRING ACCEPTED,
otherwise, output STRING REJECTED.

Your help would be gladly appreacited with the above; as I thought I
had this stuff covered & now its frustrating me as I can't produce the
results they want.
 
R

red floyd

Willing said:
[do my homework request redacted]

Show us what you've got so far, and then we'll help. Or make your best
effort and post your code. You need to put out a minimum of effort
(beyond typing the specs from your textbook). Once you've got something
posted, we can look at it and offer advice.
 
W

Willing 2 Learn

//Attempt for 1
//Suppose I want to send below
(01000110+01001101+01001100)*

int on= 1;
//int off=0;
int sent;

if (sent == 1)
cout<<"on";
if(sent == 0)
cout<<"off";
if(sent == 10)
cout<<"stop"

-------------------------------------------------------------------------------
//Clueless w/ 2
--------------------------------------------------------------------------------
//Attempt for #3

//Suppose I want to send below
(01000110+01001101+01001100)*

int main() {
char code[8];

if(code == '01000110' || code== '01001101' || code == '01001100') {
cout<<"select again or <999> to end"<<endl;
cin>>code }
else {
cout<<"Error! start over"<<endl;

return 0;
}
 
W

Willing 2 Learn

//Attempt for 1
int on= 1;
int off = 0;
int signal;


for(int i=0 ; i <10; i++) {
cout<<"Enter signal:<<endl;
cin>>signal;

if(signal == 0) {
cout<<"off"; }
if(signal == 1) {
cout<<"on";}
else {
if(signal == 01 || signal == 10) {
cout<<"end"; }

//Attempt for 2 - Clueless as to how to do this

//Attempt for 3
(01000110+01001101+01001100)* // want to generate FML with ASCII
int main() {
char num1[8], code[];
for(int i=0; i<5; i++) {
cout<<"Enter #";
cin>>code;
if(code=='01000110' || code == '01001101' || code == '01001100') {
cout<<"win" }
else {
cout<<"lose"; }
}
return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top