第三章第45题

来源:互联网 发布:知微的博客 编辑:程序博客网 时间:2024/06/01 01:33

P124

#include<stdlib.h>#include<math.h>#include<iostream.h>#include<stdio.h>#include<conio.h>long sum(int n){long s;if(n==1)s=1L;elses=n+sum(n-1);printf("n=%d\n\sum=%d\n",n,s);return s;}int main(){while(1){            int N;    scanf("%d",&N);    sum(N);}return 0;}


0 0
原创粉丝点击