经典算法详解(10)图中有多少个三角形
Posted ys99
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了经典算法详解(10)图中有多少个三角形相关的知识,希望对你有一定的参考价值。
题目:请说出下面图形中包含多少个三角形?请用一个程序完成计算。
C++版本
1 #include<iostream> 2 3 using namespace std; 4 5 const char NO_POINT = ‘0‘; 6 7 //任意的一条线 8 const char *map[] = { "ad","ab","db","ae","aj","ah","ej","eh","jh","af","ak","ai","fk","fi","ki","ag","ac","gc", 9 "de","df","dg","ef","eg","fg","bj","bk","bg","jk","jg","kg","bh","bi","bc","hi","hc","ic" }; 10 //共线的点 11 const char *line[] = { "adb","aejh","afki","agc","defg","bjkg","bhic" }; 12 13 //点是否在线上 14 int contain( const char *str, char a) { 15 int i = 0; 16 while (str[i] != ‘