The question is not difficult. We still use the vector cross product to see the figure.
Next, you only need to judge the relationship between one side and one point counterclockwise. If the cross product is greater than 0, it indicates that there is an inner angle greater than 180, that is, a concave polygon.
# Include <iostream> # include <math. h> using namespace STD; struct node {int X, Y;} p [100]; int seg (node P1, node P2, node P3) {int d = (p3.x-p1.x) * (p2.y-p1.y)-(p2.x-p1.x) * (p3.y-p1.y); If (d <0) return 1; else return 0 ;}int main () {int N; while (scanf ("% d", & n) = 1 & N) {for (INT I = 0; I <n; I ++) scanf ("% d", & P [I]. x, & P [I]. y); P [N]. X = P [0]. x, p [N]. y = P [0]. y; P [n + 1]. X = P [1]. x, p [n + 1]. y = P [1]. y; int flag = 0; If (n <= 3) Flag = 0; else {If (SEG (P [0], P [1], p [2]) {for (INT I = 3; I <n + 2; I ++) if (! SEG (P [I-2], p [I-1], p [I]) {flag = 1; break;} else flag = 0;} else flag = 1 ;} if (FLAG) printf ("Concave \ n"); else printf ("convex \ n");} return 0 ;}