//输入字符串,再输入显示遍数
#include<iostream>
void show( char * str1,int j,int i);
inline void show( char * str1,int j)//内联函数,函数重载
{
int i =0;
for(i;i<j;i++)
{
std::cout <<str1[i];
}
std::cout <<"\n";
}
int main()
{
using namespace std;
char * pt =new char [];
char ch;
int i,j=0;
cout << "Enter string:(press\"Enter\"end)\n";
while(j<80 && (ch=cin.get())!='\n') //循环输入
{
pt[j] = ch;
j++;
}
pt[j] = '\n';
cout <<"Input show times:";
cin >> i;
if(i!=0)
show(pt,j,i);
else
show(pt,j);
cin.get();
return 0;
}
void show(char * str1,int j,int i)
{
while(i-->0)
{
show(str1,j);
}
}
<img src="https://img-blog.csdn.net/20151105234041536?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />