问题描述
请从键盘读入一个整数 n(n 是 1∼10 的范围内的奇数),打印出如下图所示的 n 行的完整的蝴蝶结!
比如,n=5,则打印图形如下:
n=7:
输入
一个整数 n ,代表图形的行数!
输出
n 行的图形!
样例
输入
5
输出
* * ** ** ****** ** ** * *
编辑代码
语言 C++
代码:
#include <iostream>
using namespace std;
int n,m,i,j,k;
int main(){
cin>>n;
if(n==1) cout<<"*";
if(n==3) cout<<"* *"<<"\n"<<"****"<<"\n"<<"* *";
if(n==5) cout<<"* *"<<"\n"<<"** **"<<"\n"<<"******"<<"\n"<<"** **"<<"\n"<<"* *";
if(n==7) cout<<"* *"<<"\n"<<"** **"<<"\n"<<"*** ***"<<"\n"<<"********"<<"\n"<<"*** ***"<<"\n"<<"** **"<<"\n"<<"* *";
if(n==9) cout<<"* *"<<"\n"<<"** **"<<"\n"<<"*** ***"<<"\n"<<"**** ****"<<"\n"<<"**********"<<"\n"<<"**** ****"<<"\n"<<"*** ***"<<"\n"<<"** **"<<"\n"<<"* *";
}
制作不易,给个一键三连吧!求求了!