简化下面的编码
void fillLine() { // 25 개의 '*' 문자를 한 라인에 출력
for(int i=0; i<25; i++) cout << '*';
cout << endl; } void fillLine(int n, char c) { // n개의 c 문자를 한 라인에 출력
for(int i=0; i<n; i++) cout << c;
cout << endl; }
#include <iostream>
using namespace std;
void fillLine(int n=25,char c='*'){
//n个 c的字符串返回输出
for(int i=0;i<n;i++) cout << c;
cout << endl;
}
int main(int argc, const char * argv[]) {
fillLine();//25个 “*”在一行里面输出
fillLine(10,'%');//10个%在一行里面输出
}
结果
*************************
%%%%%%%%%%
Program ended with exit code: 0