473,467 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help Badly needed- FSA and ASCII stuff

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.

Feb 28 '06 #1
3 2383
Willing 2 Learn wrote:
[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.

Feb 28 '06 #2
//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;
}

Feb 28 '06 #3
//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;
}

Feb 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: effendi | last post by:
I have been having error messages relating to a session variable. I did a print_r of the $session and I got the following results Array ( => english => 1 => configuration => 1 ) Fatal...
7
by: Denis | last post by:
I am building a site for my college and it looks OK on PCs (IE, Netscape, Opera, not Mozilla though), but the page is displaced to the bottom of the screen on a Mac. Probably something simple,...
10
by: Ant | last post by:
Hi, I'm using an associative array to simulate a multidimensional array like this: myArray = "John"; myArray = "35"; myArray = "12345"; myArray = "01/01/1975";
20
by: Sivarn | last post by:
I'm writing a program for that takes dates as input using scanf. I want to verify that the user is inputting a full 4 digits for the year. How do I do this? I know that the return value on printf...
17
by: jensen bredal | last post by:
Hello, i'm struggling with a somehow badly understood session scenario. I provide acces to my pages based on form authentication using Session cookies. Som of my pages are supposed to be...
2
by: Sam Samnah | last post by:
I am building a custome control and I need to access the information in the hidden field (HtmlInputHidden HIH) so that when a button is pressed the information in the hidden fields value is...
1
by: Rain | last post by:
AppDomain appDomain = AppDomain.CreateDomain("appDomain", null, null); try { appDomain.Load(@"FF-DeliousDateTimeRequestor.dll"); } finally { AppDomain.Unload(appDomain); }
9
by: quyvle | last post by:
I can't seem to get this function to work correctly. I'm wondering if anyone could help me out with this. So I'm using the fscanf function to read the input stream and store each string in the...
9
by: smartbei | last post by:
Hello, I am a newbie with python, though I am having a lot of fun using it. Here is one of the excersizes I am trying to complete: the program is supposed to find the coin combination so that with...
1
by: siva041986 | last post by:
Hi there, This is Siva. I need some help in writing a program for Unix. I need to write a program using Semaphores and avoid deadlocks and starvation. If you think you can help me please let me...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.