好大的一个图片有木有,哈哈,题目来了,数出上述图形中的三角形个数。
我真的曾经十分认真的数过,我按照组成多边形的三角形的个数,从1-9依次数来,但是很悲催,我把一个多边形组成的三角形数出了九个(汗一个,我姥姥都知道只有五个),结果数出了28个。最终用代码确认结果,只有24个,仔细检查下,才发现这个错误。下面是我用c11写的代码,不得不说c11中的不少新语法,真心很好用。
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdarg.h>
using namespace std;
typedef int VERTEX;
typedef vector<VERTEX> LINE; // 共线的n个点为一条边
typedef struct _graph{
vector<VERTEX> _vertexes;
vector<LINE> _lines;
}GRAPH;
GRAPH g_graph;
int g_count = 0;