实验1-8 输出倒三角图案 (5 分)
1. 题目摘自
https://pintia.cn/problem-sets/13/problems/258
2. 题目内容
本题要求编写程序,输出指定的由“*”组成的倒三角图案。
输入格式:
本题目没有输入。
输出格式:
按照下列格式输出由“*”组成的倒三角图案。
3. 源码参考
#include<iostream>
using namespace std;
int main()
{
int i,j,n;
n=7;
for(i=1;i<=(n+1)/2;i++)
{
for(j=1;j<i;j++)
{
cout<<" ";
}
for(j=i;j<=n-i+1;j++)
{
if((j-i)%2==0)
{
cout<<"*";
}
else
{
cout<<" ";
}
}
cout<<endl;
}
return 0;
}