Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Pangram-checker/C-sharp/pangram-checker-1.cs
Normal file
15
Task/Pangram-checker/C-sharp/pangram-checker-1.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
static class Program
|
||||
{
|
||||
static bool IsPangram(this string text, string alphabet = "abcdefghijklmnopqrstuvwxyz")
|
||||
{
|
||||
return alphabet.All(text.ToLower().Contains);
|
||||
}
|
||||
|
||||
static void Main(string[] arguments)
|
||||
{
|
||||
Console.WriteLine(arguments.Any() && arguments.First().IsPangram());
|
||||
}
|
||||
}
|
||||
40
Task/Pangram-checker/C-sharp/pangram-checker-2.cs
Normal file
40
Task/Pangram-checker/C-sharp/pangram-checker-2.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
|
||||
namespace PangrammChecker
|
||||
{
|
||||
public class PangrammChecker
|
||||
{
|
||||
public static bool IsPangram(string str)
|
||||
{
|
||||
bool[] isUsed = new bool[26];
|
||||
int ai = (int)'a';
|
||||
int total = 0;
|
||||
for (CharEnumerator en = str.ToLower().GetEnumerator(); en.MoveNext(); )
|
||||
{
|
||||
int d = (int)en.Current - ai;
|
||||
if (d >= 0 && d < 26)
|
||||
if (!isUsed[d])
|
||||
{
|
||||
isUsed[d] = true;
|
||||
total++;
|
||||
}
|
||||
}
|
||||
return (total == 26);
|
||||
}
|
||||
}
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string str1 = "The quick brown fox jumps over the lazy dog.";
|
||||
string str2 = "The qu1ck brown fox jumps over the lazy d0g.";
|
||||
Console.WriteLine("{0} is {1}a pangram", str1,
|
||||
PangrammChecker.IsPangram(str1)?"":"not ");
|
||||
Console.WriteLine("{0} is {1}a pangram", str2,
|
||||
PangrammChecker.IsPangram(str2)?"":"not ");
|
||||
Console.WriteLine("Press Return to exit");
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue