摘要:
题目:在主程序中提示输入整数n,编写函数用递归的方法求1+2+3+....+n的值。#includeusing namespace std;int D(int n,int &M){M=M+n;if(n>=1) D(n-1,M);else return 0;}int main(){int n,M=0;while(cin>>n){D(n,M);cout<<"从1加到"<<n<<"的和为:"<<M<<e... 阅读全文
posted @ 2008-10-08 04:12
mzlogin
阅读(1267)
评论(0)
推荐(0)

浙公网安备 33010602011771号