递归法求三角形数(1,3,6,10,15...)

来源:互联网 发布:保研夏令营 知乎 编辑:程序博客网 时间:2024/06/01 09:00
#include<iostream>using namespace std;int Fun(unsigned int n){if(n==1)return 1;elsereturn Fun(n-1)+n;}int main(){unsigned int n;cout<<"input the number of the Num:";cin>>n;cout<<Fun(n)<<endl;return 0;}

0 0