C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help Badly needed- FSA and ASCII stuff

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Willing 2 Learn
Guest





PostPosted: Tue Feb 28, 2006 3:06 am    Post subject: Help Badly needed- FSA and ASCII stuff Reply with quote



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.
Back to top
red floyd
Guest





PostPosted: Tue Feb 28, 2006 3:06 am    Post subject: Re: Help Badly needed- FSA and ASCII stuff Reply with quote



Willing 2 Learn wrote:
Quote:
[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.
Back to top
Willing 2 Learn
Guest





PostPosted: Tue Feb 28, 2006 6:06 am    Post subject: Re: Help Badly needed- FSA and ASCII stuff Reply with quote



//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;
}
Back to top
Willing 2 Learn
Guest





PostPosted: Tue Feb 28, 2006 7:06 am    Post subject: Re: Help Badly needed- FSA and ASCII stuff Reply with quote

//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;
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.