判断是否是三角形

public static int Traingle(int a, int b, int c)

{

if (a <= 0 || b <= 0 || c <= 0)

{

return 4;

}

int[] array = new int[3] {a,b,c };

Array.Sort(array);

int min, mid, max;

min = array[0];

mid = array[1];

max = array[2];

if (max - mid < min)

{

return 4;

}

if (max == min)

{

return 1;

}

if (min == mid || mid == max)

{

return 2;

}

else return 3;

}

posted @ 2010-09-15 15:33  purplesun  阅读(328)  评论(0编辑  收藏  举报