Write a program in c++ description give in below

Write a program in C++ to minize the states of FSA(finite state Of Automata)
i)Your input of your program will must read from the fileand the file contain input as follow:
sab
-123
224
+313
+443
the upper data is ur input...s is the states(-1,2,+3,+4)
a is the transition
b is the transition
On state -1 the transition on a is 2 and on transition b is 3
On state 2 the transition on a is 2 and on transition b is 4
On state +3 the transition on a is 1 and on transition b is 3
On state +4 the transition on a is 4 and on transition b is 3

this program is related to some thoery of automata but i am practing i have tried but i cannot do this...I need help of someone can do this to me a favour build a code in c++ for me...

Best regards
omer Iqbal
Let's see what you have so far. Post your code.
hi,
I am assuming you only want to get the numbers from the file

here is some quick code to seperate the numbers into 3 value (and +/-)
and print them.

hopefully it will get you started



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include	<stdio.h>

void	printThem(char* values,bool neg,bool pos);

int	main(int argc,char** argv)
{
	FILE*	file;
	char*	buffer = new char[32];

	char	values[3];
	

	file = fopen("auto.txt","r");

	while (fgets(buffer,32,file) == buffer)
	{
		int		pos = 0;
		bool	sNeg = false;
		bool	sPos = false;
		
		if (buffer[pos] == '-')
		{
			sNeg = true;
			pos++;
		}
		else if (buffer[pos] == '+')
		{
			sPos = true;
			pos++;
		}

		for (int i=0;i<3;i++)
		{
			values[i] = buffer[pos] - 0x30;		//this line only works if numbers 0-9
			pos++;
		}

		printThem(values,sNeg,sPos);
	}


	fclose(file);
}

void	printThem(char* values,bool neg,bool pos)
{
	char	tempChar = ' '; //note space

	if (neg)
	{
		tempChar = '-';
	}
	else if (pos)
	{
		tempChar = '+';
	}

	printf("\n%c %d %d %d\n",tempChar,values[0],values[1],values[2]);
}
Topic archived. No new replies allowed.