/*
*copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称:hellow.cpp
*作者:田甜
*完成日期:2016年3月19日
*版本号:v1.0
*
*问题描述:输出*图案
*输入描述:无
*程序输出:*图案
*/
问题及代码:
#include<iostream>
using namespace std;
int main()
{
int i,m,n;
cout<<" *"<<endl;//输出图案顶部
for(i=1;i<=4;i++)//控制输出总行数
{
for(m=0;m<5-i;m++)
cout<<" ";//输出前半部分空格
cout<<"*";
for(n=0;n<2*i-1;n++)//输出后半部分空格
cout<<" ";
cout<<"*"<<endl;
}
cout<<"***********"<<endl;//输出图案底部
return 0;
}
运行结果:
知识点总结:
运用循环的嵌套输出图案。
学习心得:
运用循环嵌套可以输出多种图案。