我需要让控制台打印每“页”22 个字符的 ASCII 字符。输入“key”后,它们将打印接下来的 22 个 ASCII 字符,依此类推。问题出在“翻页”问题上。
这是我的代码:
static void Main(string[] args)
{
int i = 0;
while (i <= 22)
{
Console.Write(i + " = " + (char)i);
if (i < 22)
{
Console.Write((char)10);
}
i++;
}
Console.Write("Please press any key to turn page");
Console.ReadKey();
while (i > 22 && i <= 44)
{
Console.Write(i + " = " + (char)i);
if (i < 44)
{
Console.Write((char)10);
}
i++;
}
Console.Write("Please press any key to turn page");
Console.ReadKey(); …Run Code Online (Sandbox Code Playgroud) 这是我第一次尝试没有输入的方法。这是代码:
int factorial(int a)
{
int i = 1, result = 1;
while (i <= a)
{
result = result * i;
i++;
}
return result;
}
int double_factorial(int a)
{
int i = 2, result = 1;
while (i <= a)
{
result = result * i;
i = i + 2;
}
return result;
}
long double pi()
{
unsigned long int n = 4294967295;
unsigned long int i = 0;
long double result = 0;
while (i …Run Code Online (Sandbox Code Playgroud)