
Random Char
By: a guest on
Apr 30th, 2012 | syntax:
C# | size: 0.98 KB | hits: 38 | expires: Never
class Program
{
public static bool name(string user, char random)
{
for (int i = 0; i < user.Length; i++)
{
if (user[i] == random) // פה זה רושם טעות ..
{
return true;
}
}
return false;
}
static void Main(string[] args)
{
char[] words = { 'a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
Random randnum = new Random();
int rand = randnum.Next(0, words.Length + 1);
char random = words[rand];
string user = Console.ReadLine();
bool flag = name(user, random);
if (flag)
Console.WriteLine("The random word is in your name!!");
else
Console.WriteLine("false");
}
}