题目:
解题思路:
两层循环查找,第一次循环中初始化 destination 为 path中每次旅行的终点作为最终的终点。二次循环查找当前 destination ,若是作为某次旅行的起点,说明不是最后的终点。
char* destCity(char ***paths, int pathsSize, int *pathsColSize) {char *destination = NULL;for (int i = 0; i < pathsSize; ++i) {int j;destination = paths[i][1];for (j = 0; j < pathsSize; ++j) {if (strcmp(paths[j][0], destination) == 0) {destination = NULL;break;}}if (j == pathsSize && destination != NULL) {break;}}return destination;
}