struct Word
{
int IndexStart = -1;
int IndexEnd = -1;
};
vector<char> Replace(char input[], char find[], char replace[])
{
auto word = new Word();
map<int, Word*> words;
vector<char> result;
const auto inputReverse = input;
std::reverse(inputReverse, input + strlen(input));
for (auto indexInput = 0; indexInput < strlen(input); indexInput++)
{
word = new Word();
auto countFounded = 0;
for (auto indexReplace = 0; indexReplace < strlen(find); indexReplace++)
{
if (input[indexInput + indexReplace] == find[indexReplace]) {
if (word->IndexStart == -1)
{
word->IndexStart = indexInput + indexReplace;
}
countFounded++;
if (countFounded == strlen(find))
{
word->IndexEnd = indexInput + indexReplace;
words.emplace(word->IndexStart, word);
break;
}
}
else {
break;
}
}
}
for (auto indexInput = 0; indexInput < strlen(input); indexInput++)
{
if (words.count(indexInput) > 0)
{
auto word = words.find(indexInput);
for (auto indexReplace = 0; indexReplace < strlen(replace); indexReplace++)
{
result.push_back(replace[indexReplace]);
}
indexInput += word->second->IndexEnd - word->second->IndexStart;
}
else
{
result.push_back(input[indexInput]);
}
}
std::reverse(result.begin(), result.end());
return result;
}
char input[] = "test #1 - (...) test #2 - (.....) test #3 - (..-...-....-.....)";
char find[] = "..";
char replace[] = "**";
const auto result = Replace(input, find, replace);
for (auto index = 0; index < result.size(); index++)
{
std::cout << result[index];
}
cout << endl;
Правильно ли я написал?
Не могу понять где ошибка ребят , у меня или в задании
await Task.Run(async () =>
{
for (int i = 18; i < 30; i++)
{
await Task.Delay(1000);
itemStates.Where(user => user.Name.Equals("Не анимэшник")).FirstOrDefault().Age = i;
}
});