我看了一下c++的练习书上
有一个
让我们打印出一个
菱形
好了上代码!
(跪求赞和评论!!)
(跪求赞和评论!!)
(跪求赞和评论!!)
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
for (int i=1;i<n;i++)
{
for (int j=1;j<(n-1-i);j++)
{
cout<<" ";
}
for (int j=1;j<2*i+1;j++)
{
cout<<"*";
}
cout<<endl;
}
for (int i=1;i<n-1;i++)
{
for (int j=1;j<i+1;j++)
{
cout<<" ";
}
for (int j=1;j<2*(n-1)-(1+2*i);j++)
{
cout<<"*";
}
cout<<endl;
}
return 0;
}
加油