111,094
社区成员




if(Math.Abs((a[0]-a[1])*(a[1]-a[2])+0.5)==1.5)
{
}
if(Math.Abs((a[0]-a[1])*(a[1]-a[2])*2+1)==3)
{
}
if((a[0]-a[1])*(a[1]-a[2])==1||(a[0]-a[1])*(a[1]-a[2])==-2)
{
}
namespace WindowsApplication13
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
List<int> Numbers = new List<int>();
Numbers.Add(6);
Numbers.Add(5);
Numbers.Add(4);
MessageBox.Show(IsNearBy(Numbers).ToString());
}
bool IsNearBy(List<int> Numbers)
{
Numbers.Sort();
for (int i = Numbers[0]; i <= Numbers[Numbers.Count - 1]; i++)
if (Numbers.IndexOf(i) == -1)
return false;
return true;
}
}
}
bool CheckArray(int[] array)
{
Array.Sort(array);
for (int i = 1; i < array.Length; i++)
{
if (array[i] == array[i - 1])
return false;
}
return array[array.Length-1] - array[0] == array.Length - 1;
}
bool CheckArray(int[] array)
{
if (array.Distinct().Count() != array.Length)
return false;
return array.Max() - array.Min() == array.Length - 1;
}