[恢]hdu 2108
2011-12-21 11:00:01
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2108
题意:中文,判断是否凸。
代码:
# include <stdio.h>
typedef struct POINT{
int x, y ;
}point ;
point pt[1010] ;
int n ;
int direction (int x1, int y1, int x2, int y2)
{
return x1*y2 - x2*y1 ;
}
int test ()
{
int i ;
pt[n] = pt[0], pt[n+1] = pt[1] ;
for (i = 2 ; i <= n+1 ; i++)
if (direction ( pt[i-1].x-pt[i-2].x,
pt[i-1].y-pt[i-2].y,
pt[i].x-pt[i-1].x,
pt[i].y-pt[i-1].y) < 0 )
return 0 ;
return 1 ;
}
int main ()
{
int i ;
while (~scanf ("%d", &n) && n)
{
if (n > 1000) while (1) ;
for (i = 0 ; i < n ; i++)
scanf ("%d%d", &pt[i].x, &pt[i].y) ;
puts (test() ? "convex" : "concave") ;
}
return 0 ;
}