Skip to main content

Breadth-First Search in C#

0 likes • Oct 15, 2022 • 22 views
C#
Loading...

More C# Posts

Untitled

0 likes • Aug 5, 2023 • 5 views
C#
public class King {
fewf
}

Luhn Algorithm

0 likes • Nov 18, 2022 • 5 views
C#
// C# program to implement
// Luhn algorithm
using System;
class GFG {
// Returns true if given
// card number is valid
static bool checkLuhn(String cardNo)
{
int nDigits = cardNo.Length;
int nSum = 0;
bool isSecond = false;
for (int i = nDigits - 1; i >= 0; i--)
{
int d = cardNo[i] - '0';
if (isSecond == true)
d = d * 2;
// We add two digits to handle
// cases that make two digits
// after doubling
nSum += d / 10;
nSum += d % 10;
isSecond = !isSecond;
}
return (nSum % 10 == 0);
}
// Driver code
static public void Main()
{
String cardNo = "79927398713";
if (checkLuhn(cardNo))
Console.WriteLine("This is a valid card");
else
Console.WriteLine("This is not a valid card");
}
}

Untitled

0 likes • Aug 21, 2023 • 10 views
C#
using System;
class Yeet{
public int value = 1;
public override string ToString (){
return value.ToString();
}
}
class Bruh{
public Yeet skeet;
public override string ToString (){
return skeet.ToString();
}
}
class HelloWorld {
static void Main() {
Yeet yeet = new Yeet();
Bruh bruh = new Bruh{ skeet = yeet };
++(yeet.value);
Console.WriteLine(yeet);
Console.WriteLine(bruh);
}
}