Untitled diff

Creado El diff nunca expira
4 eliminaciones
39 líneas
6 adiciones
41 líneas
static string insert(string text, string wort, int pos)
static string insert(string text, string wort, int pos)
{
{
if (pos == 0)
if (pos == 0)
{
{
return wort + " " + text;
return wort + " " + text;
}
}
string newtext = "";
string newtext = "";
int spacecount = 0;
int spacecount = 0;
bool inserted = false;
bool inserted = false;
for (int i = 0; i < text.Length; i++)
for (int i = 0; i < text.Length; i++)
{
{
newtext += text[i];
newtext += text[i];
if (inserted == false)
if (inserted == false)
{
{
if (pos > spacecount)
{
return wort + " " + text;
}
if (text[i] == ' ')
if (text[i] == ' ')
{
{
spacecount++;
spacecount++;
}
}
if (spacecount == pos)
if (spacecount == pos)
{
{
newtext += wort + " ";
newtext += wort + " ";
inserted = true;
inserted = true;
}
}
}
}
}
}
if (pos > spacecount)
{
return text + " " + wort;
}
return newtext;
return newtext;
}
}