close

Вход

Забыли?

вход по аккаунту

?

отчет3 (2)

код для вставкиСкачать
 ???????????? ?????? ? ?????, ?????? ?? ?????? ???????
????????????? ????????? ??????????? ????? ????? ??????
????????? ????'??????? ????
??????? ??????????????? ????????????? ??????
????
? ???????????? ?????? ?3
"?????????? ???????? ???????"
?????????? "?????? ?????????? ?? ??????????? ??????"
????????????? "?????????????? ??????? ????????? ??????"
6.050101-??.??.03-303.2910302
???????___________?.?.??????? (??????)
____________
(????)
????????___________?.?.?????????
(??????)
____________
(????)
???????? - 2012
??????? 1
??????????? ?????????? ???????? ??????? ?????????? ?? ????????, ?????????? ? ??????? 1.
?
???i????ABCD1 a b c d ab?c bd?/\ cd?a ac?/\ aacbbadcd dcabbaaddc?????????? ????????? ??????? ?? ????????? ?????????????? ?????????? ???????:
??? ?: ??? D:
????????: 1. ? ????????????? ????????????? ??????????? ????????? ???????? ???????????, ???? ????? ???? ??????? ? ????? ?????.
2. ? ????? ????? ????????? ???????? (??????) ????????? ?????? ????? ????????? ???????????.
3. ?? ????????? ? ????? ????? ??????????? ?? ????? ????? ????????? ??????????? (???????????? ?????).
4. ????? 1-3 ???????????? ?? ??? ??? ?? ??????? ????????, ???? ???? ?? ???? ???? ????????? ????? ??, ?? ????? ?? ??????????? ?? ?????????
??????? ????????: public class Main {
static int nLevel = 0;
public String Rules(String inStr, int inRule, String[] rs) {
String newStr = inStr.substring(0, inRule);
newStr += rs[1];
newStr += inStr.substring(inRule + rs[0].length());
return newStr;
}
public void Marcov(String inStr, String[][] rs, int l) {
nLevel++;
String inputStr = inStr;
String[][] rules = rs;
int level = l;
++level;
String newStr;
int count =0;
for (int i = 0; i < rules.length; i++) {
int inRule;
inRule = inputStr.indexOf(rules[i][0]);
if (inRule != -1) {
for(int j=0; j<nLevel; j++){
System.out.print(" ");
}
newStr = Rules(inputStr, inRule, rules[i]);
count++;
System.out.println("?????? = " + level + ", " + inputStr + " -> " + rules[i][0] + " ????????? " + rules[i][1] + " -> " + newStr);
Marcov(newStr, rules, level);
}
}
nLevel--;
}
public static void main(String[] args) {
DataFromFile dff = new DataFromFile();
Main m = new Main();
dff.readFile();
System.out.println("???????: ");
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 2; j++) {
System.out.print(dff.finalRules[i][j]+" ");
}
System.out.println();
}
for (int k=0;k<2;k++) {
System.out.println("????? ?? ?????:\n" + dff.finalStrings[k]);
System.out.println("?????????? ???????? ???????:");
m.Marcov(dff.finalStrings[k], dff.finalRules, 0);
}
}
}
public class DataFromFile {
static String[][] finalRules = new String[4][];
static String[] finalStrings = new String[2];
public void readFile() {
try {
LineNumberReader str_in = new LineNumberReader(new BufferedReader(new FileReader("inputStr.txt")));
LineNumberReader rules_in = new LineNumberReader(new BufferedReader(new FileReader("inputRules.txt")));
String[] rules = new String[4];
for (int i=0;i<rules.length;i++){
finalRules[i] = new String[2];
}
for (int i = 0; i < 2; i++) {
finalStrings[i] = str_in.readLine();
}
for (int i = 0; i < 4; i++) {
rules[i] = rules_in.readLine();
}
for (int i=0;i<4;i++){
finalRules[i][0]= rules[i].substring(0, rules[i].indexOf("-"));
finalRules[i][1] = rules[i].substring(rules[i].indexOf("-") + 1, rules[i].length());
}
finalRules[3][1] = "";
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 2; j++) {
if (finalRules[i][j] == " ") {
finalRules[i][j] = "";
}
}
}
} catch (IOException ex) {
System.out.println("Error. File not found.");
}
}
}
?????????:
Документ
Категория
Без категории
Просмотров
7
Размер файла
631 Кб
Теги
отчет
1/--страниц
Пожаловаться на содержимое документа