资源简介
万海课程作业,包含源代码,txt以及脚本文件
代码片段和文件信息
import java.util.*;
import java.io.*;
class DFA
{
boolean recognizeString(int move[][] int accept_state[] String word)
{
int state = 0;
int intChar = 0;
for(int i = 0; i < word.length(); i++)
{
char c = word.charAt(i); //逐个读取字符
intChar = c - ‘a‘; //计算输入字符所代表的数字
state = move[state][intChar]; //状态转换
}
for(int j = 0; j < accept_state.length; j++)
{
if(state == accept_state[j]) //判断最终状态是否为接受状态
return true;
}
return false;
}
public static void main(String args[]) throws IOException
{
int n m;
BufferedReader in = new BufferedReader(new FileReader(“DFA.in“));
StringTokenizer st = new StringTokenizer(in.readLine());
n = Integer.parseInt(st.nextToken());
m = Integer.parseInt(st.nextToken());
while (n != 0)
{
int[][] move = new int[n][m];
for(int i=0; i {
st = new StringTokenizer(in.readLine());
for (int j=0; j move[i][j] = Integer.parseInt(st.nextToken());
}
String[] temp = in.readLine().split(“\\s“);
int[] accept = new int[temp.length];
for (int i=0; i String word = in.readLine();
while (word.compareTo(“#“) != 0)
{
DFA dfa = new DFA();
if (dfa.recognizeString(move accept word)) System.out.println(“YES“); else System.out.println(“NO“);
word = in.readLine();
}
st = new StringTokenizer(in.readLine());
n = Integer.parseInt(st.nextToken());
m = Integer.parseInt(st.nextToken());
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 59 2011-10-07 12:02 编译原理DFA_NFA\DFA\DFA.bat
文件 89 2009-03-16 00:20 编译原理DFA_NFA\DFA\DFA.in
文件 1585 2011-10-07 15:08 编译原理DFA_NFA\DFA\DFA.java
文件 747 2011-10-07 15:19 编译原理DFA_NFA\DFA\DFA.txt
文件 59 2011-10-07 14:34 编译原理DFA_NFA\NFA\NFA.bat
文件 90 2009-03-16 00:27 编译原理DFA_NFA\NFA\NFA.in
文件 2994 2011-10-07 15:04 编译原理DFA_NFA\NFA\NFA.java
文件 1541 2011-10-07 15:34 编译原理DFA_NFA\NFA\NFA.txt
目录 0 2011-10-07 15:37 编译原理DFA_NFA\DFA
目录 0 2011-10-07 15:37 编译原理DFA_NFA\NFA
目录 0 2011-10-07 15:37 编译原理DFA_NFA
----------- --------- ---------- ----- ----
7164 11
- 上一篇:STM32延时中断LED
- 下一篇:dsp常用例程汇编语言
评论
共有 条评论