Synchronization of old projects
Part1
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
namespace Lesson
|
||||
{
|
||||
class Program
|
||||
{
|
||||
#region 练习题一 课上有不写了
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 练习题二
|
||||
static int JieCheng(int max)
|
||||
{
|
||||
if (max == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return max * JieCheng(max - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 练习题三
|
||||
static int JieChengHe(int num)
|
||||
{
|
||||
if (num == 1)
|
||||
{
|
||||
return JieCheng(1);
|
||||
}
|
||||
return JieCheng(num) + JieChengHe(num-1);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 练习题四
|
||||
static void Bamboo(float length, int day)
|
||||
{
|
||||
Console.WriteLine("长度为" + length);
|
||||
length /= 2;
|
||||
day--;
|
||||
if (day < 0)
|
||||
{
|
||||
Console.WriteLine("长度为" + length);
|
||||
return;
|
||||
}
|
||||
Bamboo(length, day);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 练习题五
|
||||
static bool Fun(int num)
|
||||
{
|
||||
Console.WriteLine(num);
|
||||
return num == 200 || Fun(num + 1);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine(JieCheng(5));
|
||||
|
||||
Console.WriteLine(JieChengHe(10));
|
||||
|
||||
Bamboo(100,10);
|
||||
|
||||
Fun(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user