LeetCode刷题中遇到的bug

以下bug都是本人用C刷题时遇到的

bug1:函数为被明确定义

solution.c: In function ‘isSubtree’
Line 13: Char 12: warning: implicit declaration of function ‘isSameTree’; did you mean ‘isSubtree’? [-Wimplicit-function-declaration]
     return isSameTree(s,t)||isSubtree(s->left,t)||isSubtree(s->right,t);
            ^~~~~~~~~~
            isSubtree
solution.c: At top level
Line 15: Char 6: error: conflicting types for ‘isSameTree’
 bool isSameTree(struct TreeNode *s,struct TreeNode *t){
      ^~~~~~~~~~

主函数想调用子函数,必须把子函数的定义放在主函数前

bug2:测试用例通过,提交不通过

好几次都遇到这个问题,特别头疼,后来查了一下,原来是全局变量的原因,以后写代码还是不要用全局变量了,本身就是个不好的习惯

posted @ 2020-04-17 19:56  咸鱼不闲咋整啊  阅读(384)  评论(0编辑  收藏  举报