实现一个多行输出的程序,输出内容为:
*
***
*****
*******
*****
***
*
#include<iostream> using namespace std; int main(){ cout<<"*\n"<<"***\n"<<"*****\n"<<"*******\n"<<"*****\n"<<"***\n"<<"*\n"; }
#include<iostream>
using namespace std;
void print(int count, char c);
int main(){
int rowCount, count;
char c;
cout<<"please input count of rows: ";
cin>>rowCount;
cout<<"please character used to show: ";
cin>>c;
for(int i =0; i < rowCount; i++){
count = (i<=rowCount/2?2*i+1:2*(rowCount/2*2-i)+1);
print(count, c);
// if(i <= rowCount/2){
// print(2*i+1, '*');
// }else{
// print(2*(rowCount/2*2-i)+1, '*');
// }
}
return 0;
}
void print(int count, char c){
for(int i = 0; i < count; i++){
cout<<c;
}
cout<<endl;
}
include<iostream>
using namespace std;
int main()
{
cout<<"*"<<endl;
cout<<"***"<<endl;
cout<<"*****"<<endl;
cout<<"*******"<<endl; cout<<"*****"<<endl;
cout<<"***"<<endl;
cout<<"*"<<endl;
return 0;
}