C#
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/// <summary>
/// 百鸡百钱
/// </summary>
private static void baijibaiqian()
{
for (int a = 0; a < 100; a++)
{
for (int b = 0; b < 100; b++)
{
for (int c = 0; c < 100; c++)
{
if ((a + b + c == 100) && (5 * a + 3 * b + c / 3 == 100) && (c % 3 == 0) && a != 0 && b != 0 && c != 0)
{
Console.WriteLine("a={0},b={1},c={2}", a, b, c);
Console.ReadLine();
}
}
}
}
}
/// <summary>
/// 一百个不重复的随机数数组
/// </summary>
private static void randomNum()
{
int[] intArr = new int[10];
ArrayList myList = new ArrayList();
Random rnd = new Random();
while (myList.Count < 10)
{
int num = rnd.Next(1, 11);
if (!myList.Contains(num))
myList.Add(num);
}
for (int i = 0; i < 10; i++)
{
intArr[i] = (int)myList[i];
Console.WriteLine(intArr[i]);
Console.ReadLine();
}
}
/// <summary>
/// 求n!
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static int result(int n)
{
if (n >0 && n <= 1)
{
return 1;
}
else
{
return n*result(n-1);
}
}
public static int Foo(int i)
{
if (i <= 0)
{
return 0;
}
else if (i > 0 && i <= 2)
{
return 1;
}
else
{
return Foo(i - 1) + Foo(i - 2);
}
}
/// <summary>
/// 冒泡排序
/// </summary>
private static void maopao(int [] array)
{
Console.WriteLine("排序前:");
for (int k = 0; k < array.Length; k++)
{
Console.Write(array[k]+",");
}
//Console.Read();
int temp = 0;
for (int i = 0; i < array.Length - 1; i++)
{
for (int j = i + 1; j < array.Length; j++)
{
if (array[j] < array[i])
{
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}