递归函数解决n到m之间求和问题

int main()
{
     int n,m;
    int result=0;
     scanf("%d %d",&n,&m);
     result=fun(n,m);
     printf("%d",result);
}
int fun(int n,int m){
        int count=0;
        if(m==n){
            count=n;
        }else{
            count=m+fun(n,m-1);

        }
        return count;
    }

 

相关文章:

  • 2021-11-17
  • 2021-08-05
  • 2021-05-05
  • 2021-07-08
  • 2021-07-21
  • 2022-01-08
  • 2022-12-23
  • 2021-07-23
猜你喜欢
  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
相关资源
相似解决方案