标题:关于递归函数的问题
只看楼主
FrankloveCyy
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2019-5-5
结帖率:11.11%
已结贴  问题点数:10 回复次数:1 
关于递归函数的问题
#include<stdio.h>
long recursion (int n);
int main(void)                                                                           C:\Users\Lenovo\AppData\Local\Temp\ccIUDdP6.o        In function `main':
{
        int n;
        long result;
        printf("input a integer number:\n");
        scanf("%d",&n);
        result=recursion(n);                                                              C:\Users\Lenovo\Desktop\白玉\练习41.cpp        undefined reference to `recursion(int)'
        printf("%d!=%ld\n",n,result);                                                     C:\Users\Lenovo\AppData\Local\Temp\ccIUDdP6.o        In function `recursiong(int)':
}                                                                                         C:\Users\Lenovo\Desktop\白玉\练习41.cpp        undefined reference to `recursion(int)'
long recursiong(int n)                                                                    C:\Users\Lenovo\Desktop\白玉\collect2.exe        [Error] ld returned 1 exit status
{
        long temp_result;
        if(n<0)
        {
                printf("n<0,input error!\n");
        }
        else if(n==0||n==1)
        {
                temp_result=1;
        }
        else
        {
                temp_result=recursion(n-1)*n;
        }
        return temp_result;
}
如各位看到了,这段递归函数的相关程序,我是按照小甲鱼老师的例题照打的,可是一直编译不通过,右边的是程序显示出错误的地方,可是就是解决不了,按理说 recursion不是已经在头文件那里定义了吗?怎么程序还是会报错?
搜索更多相关主题的帖子: 递归 函数 long int Users 
2019-05-25 11:50
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:507
帖 子:8890
专家分:53117
注 册:2011-1-18
得分:10 
那你仔细检查一下单词是否拼写错了?多了个g
2019-05-25 12:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-494940-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.132018 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved