Алгоритмическое мышление при решении задач (на примере языка C#). Шамшев А.Б - 60 стр.

UptoLike

Составители: 

60
string oneCharStr = "" + c;
return " .,?!".Contains(oneCharStr);
}
public int getWordLength(int index) {
int res = 0;
for (int i = index; i < str.Length; i++) {
if (isSeparator(str[i])) {
break;
}
res = res + 1;
}
return res;
}
public void processString(string lastStr) {
for (int i = 0; i < str.Length; i++) {
if (isSeparator(str[i])) {
continue;
}
int len = getWordLength(i);
string word = str.Substring(i, len);
if (needDelWord(word, lastStr)) {
str = str.Remove(i, len);
} else {
i = i + len;
}
}
}
}
public class FileWorker {
public void processFile(string inFileName, string
outFileName) {
try {
string[] content = File.ReadAllLines(inFileName);
if (content.Length == 0) {
throw new ApplicationException("в файле нет строк");
}
string lastStr = content[content.Length - 1];
string[] resLines = new string[content.Length];
for (int i = 0; i < content.Length;i++ ) {
StringWorker worker = new StringWorker();
worker.str = content[i];
worker.processString(lastStr);
resLines[i] = worker.str;
}
File.WriteAllLines(outFileName, resLines);
} catch {
Console.WriteLine("ошибка");
}
}
}
}