C#,125个字节
using System;class X{static void Main(string[]a){Console.Write(a[0].Insert(new Random().Next(a[0].Length-2)+1," ~BOO!~ "));}}
展开:
using System;
class X
{
static void Main(string[] a)
{
Console.Write(a[0].Insert(new Random().Next(a[0].Length - 2) + 1, " ~BOO!~ "));
}
}
此解决方案假定将字符串作为第一个命令行参数传入。这对于C#来说不是很常见(stdin更正常),因此我还提供了一个使用常规stdin的解决方案:
C#,139个字节
using System;class X{static void Main(){var x=Console.In.ReadToEnd();Console.Write(x.Insert(new Random().Next(x.Length-2)+1," ~BOO!~ "));}}
展开:
using System;
class X
{
static void Main()
{
var x = Console.In.ReadToEnd();
Console.Write(x.Insert(new Random().Next(x.Length - 2) + 1, " ~BOO!~ "));
}
}