add Programmyday form github
This commit is contained in:
10
DoppelteBuchstaben/DoppelteBuchstaben.csproj
Normal file
10
DoppelteBuchstaben/DoppelteBuchstaben.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
42
DoppelteBuchstaben/DuplicateChars.cs
Normal file
42
DoppelteBuchstaben/DuplicateChars.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DoppelteBuchstaben
|
||||
{
|
||||
internal class DuplicateChars
|
||||
{
|
||||
private string _text;
|
||||
public bool ContainsDuplicateChars(string text)
|
||||
{
|
||||
for (int i = 0; i < text.Length; i++)
|
||||
{
|
||||
for (int j = i + 1; j < text.Length; j++)
|
||||
{
|
||||
if (text[i] == text[j])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public string RemoveDuplicateChars(string text)
|
||||
{
|
||||
for (int i = 0; i < text.Length; i++)
|
||||
{
|
||||
for (int j = i + 1; j < text.Length; j++)
|
||||
{
|
||||
if (text[i] == text[j])
|
||||
{
|
||||
this._text = text.Remove(j);
|
||||
return this._text;
|
||||
}
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
DoppelteBuchstaben/Program.cs
Normal file
13
DoppelteBuchstaben/Program.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace DoppelteBuchstaben
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
DuplicateChars duplicate = new DuplicateChars();
|
||||
string text = Console.ReadLine();
|
||||
Console.WriteLine(duplicate.ContainsDuplicateChars(text));
|
||||
Console.WriteLine(duplicate.RemoveDuplicateChars(text));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user