Day6. Namespace style
This commit is contained in:
11
344. Reverse String/344. Reverse String.csproj
Normal file
11
344. Reverse String/344. Reverse String.csproj
Normal file
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>_344._Reverse_String</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
11
344. Reverse String/Program.cs
Normal file
11
344. Reverse String/Program.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace _344._Reverse_String;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var arr = "Hello, World!".ToArray();
|
||||
new Solution().ReverseString(arr);
|
||||
Console.WriteLine(String.Join("", arr));
|
||||
}
|
||||
}
|
||||
14
344. Reverse String/Solution.cs
Normal file
14
344. Reverse String/Solution.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace _344._Reverse_String;
|
||||
|
||||
public class Solution
|
||||
{
|
||||
public void ReverseString<T>(T[] arr)
|
||||
{
|
||||
for (int i = 0; i < arr.Length / 2; i++)
|
||||
{
|
||||
T buf = arr[i];
|
||||
arr[i] = arr[arr.Length - 1 - i];
|
||||
arr[arr.Length - 1 - i] = buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user