C++primer plus第六版课后编程题答案8.1
8.1
#include <iostream> #include <string> 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++;//每调用一次++ }
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步