题目链接:
http://acm.split.hdu.edu.cn/showproblem.php?pid=2108
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1e3+10;
#define met(a,b) memset(a,b,sizeof(a))
struct node
{
int x,y;
}s[maxn];
int get(int a,int b,int c)
{
int t;
t=(s[a].x-s[c].x)*(s[b].y-s[c].y)-(s[b].x-s[c].x)*(s[a].y-s[c].y);
return t;
}
int main()
{
int n;
while(scanf("%d",&n)!=EOF&&n!=0)
{
for(int i=0;i<n;i++)
scanf("%d%d",&s[i].x,&s[i].y);
int t=0;
for(int i=0;i<n;i++)
{
t=get(i%n,(i+1)%n,(i+2)%n);
if(t<0)
break;
}
if(t>=0)
printf("convex\n");
else
printf("concave\n");
}
}
原文:http://www.cnblogs.com/TAT1122/p/5855682.html