我对此很新,但我一直想着 但是出来的是来自hapazadly排列的角色,我也无法正确创造一个完美的“g”波,波也应该出现从顶端流出并从底端删除 输出:
g
gg
ggg
gggg
ggg
gg
g
g
gg
ggg
gggg
ggg
gg
g
g
gg
ggg
gggg
ggg
gg
g
g
gg
ggg
gggg
ggg
gg
g
.
dim m as string
dim s as string = "g" + environment.newline + "gg"
+ environment.newline + "ggg" + environment.newline + "gggg"
+ environment.newline + "ggg" + environment.newline + "gg"
+ environment.newline + "g"
m = "s"+ Environment.Newline + "s"
richtextbox1.text = m
答案 0 :(得分:1)
这是C#
string s = "g" + Environment.NewLine + "gg" + Environment.NewLine + "ggg" + Environment.NewLine +
"gggg" + Environment.NewLine + "ggg" + Environment.NewLine + "gg" + Environment.NewLine + "g";
StringBuilder sb = new StringBuilder();
for (Int32 i = 0; i < 10; i++) sb.AppendLine(s);
string wave = sb.ToString();
答案 1 :(得分:0)
可能这是一种矫枉过正,但它很有趣 它是一个C#控制台应用程序,它使REAL波不是由g构成的锯波。
它没有经过优化,因此有些表达式应该比它们更复杂(例如构建空间函数可能有更好的方法)。
如果您不想要动画
,可以删除Task.Delayclass Program
{
const int NUM_WAVES = 5;
const double WAVES_LENGTH = 20;
const double WAVE_WIDTH = 20;
static void Main(string[] args)
{
string s = "";
for (int waves = 0; waves < NUM_WAVES; waves++)
{
for (double i = 0; i < WAVES_LENGTH; i++)
{
int width = (int)((Math.Cos((i / WAVES_LENGTH) * 360 * Math.PI / 180)) * WAVE_WIDTH);
s = BuildSpace(width + (int)WAVE_WIDTH);
Task.Delay(25).Wait();
Console.WriteLine(s + "g");
}
}
Console.ReadLine();
}
private static string BuildSpace(int i)
{
string s="";
for (int y = 0; y < i; y++)
s += " ";
return s;
}
}
答案 2 :(得分:0)
for (int k = 0; k < 10; k++)
{
for (int j = 1; j <= 4; j++)
{
for (int m = 0; m < j; m++)
{
Console.Write("g");
}
Console.WriteLine();
}
for (int j = 4; j > 0; j--)
{
for (int m = 0; m < j; m++)
{
Console.Write("g");
}
Console.WriteLine();
}
}
只需改变k和j去的地方并开始改变大小。