我有关于面向对象程序设计C++的试题,有谁帮我做一下?

2025-02-28 21:10:56
推荐回答(2个)
回答1:


#include

int sum(int n)
{
if (n==1)
return 1;
else
return n+sum(n-1);
}

void main()
{
cout<}


1.
i,s=15,56
2.
2 3
4 5
3.
Constructing.
Copy Constructing.
Copy Constructing.
15
Destructing
Destructing
Destructing

回答2:

1、public Int16 sum(Int16 n)
{
if n = 1
return 1;
else
return (n + sum(n-1));
}