Shape of HDU - http://acm.hdu.edu.cn/showproblem.php?pid=2108
代码
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define MXN 1000
struct point{int x, y;}p[MXN];
LL cross(point o, point a, point b){ // 差积
return (a.x-o.x)*(b.y-o.y) - (b.x-o.x)*(a.y-o.y);
}
int main(){
int n, i;
while(scanf("%d", &n)){
if(n == 0) break;
for(i = 0; i < n; i++) scanf("%d %d", &p[i].x, &p[i].y);
for(i = 0; i < n; i++){
// 点序为逆时针, 默认不少于3个点
if(cross(p[(i+n-1)%n], p[i], p[(i+1)%n]) <= 0 ) break;
}
if(i == n) printf("convex\n");
else printf("concave\n");
}
return 0;
}