用c语言编写程序,求Cn2,一种方法是直接求,也即n*(n-1)/2, 第二种是用递归法。请帮忙解答!

[复制链接]
查看11 | 回复1 | 2013-4-1 10:16:38 | 显示全部楼层 |阅读模式
能直接算出,为什么要用递归?void fun2(unsigned int *sum, unsigned int x, unsigned int h){
sum += x;
if (h-1)
fun2(*sum, x, h-1);}unsigned int fun1(unsigned int x){
unsigned int sum=0;
if (x-1)
fun2(*sum, x, x-1);
return sum/2;}...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行