8.1
#include
#include
using std::cout;
using std::cin;
using std::endl;
using std::string ;
void print(const string &s,int count=0);
static int number=0;//记录被调用的次数
void main81()
{
print(“I love you”);
print(“Can you”);
print(“haha”,100);
print(“I love you”);
print(“ooo”,0);//这里的第二个参数为0了
print(“Can you”);
print(“lalala”,50);
system(“pause”);
}
void print(const string &s,int count)
{
if(count==0)
cout<<s<<endl;
else
for(int i=0;i<number;i++)
cout<<s<<endl;
number++;//每调用一次++
}
—————————————————————————————————————————————————— //写的错误或者不好的地方请多多指导,可以在下面留言或者给我发邮件,指出我的错误以及不足,以便我修改,更好的分享给大家,谢谢。 转载请注明出处:https://www.royalchen.com/ author:royalchen Email:royalchen@royalchen.com ———————————————————————————————————————————————————
- 本文作者: royalchen
- 本文链接: http://www.royalchen.com/2016/02/24/cprimerplus第六版课后编程题答案81/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!