用循环语句编程打印如下图案:
%
%%%
%%%%%
%%%%%%%
%%%%%%%%%
%%%%%%%%%%%
%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
%%%%%%%%%%%%%
%%%%%%%%%%%
%%%%%%%%%
%%%%%%%
%%%%%
%%%
%
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
for (int i = 10; i > 1; i--)
{
for (int j = 0; j <= i; j++)
{
cout << ' ';
}
for (int k = 0; k < 20 - (2 * i) - 1; k++)
{
cout << '%';
}
cout << endl;
}
for (int i = 1; i < 10; i++)
{
for (int j = 0; j <= i; j++)
{
cout << ' ';
}
for (int k = 0; k < 20 - (2 * i) - 1; k++)
{
cout << '%';
}
cout << endl;
}
} #include <iostream>
using namespace std;
int main()
{
for(int i=1;i<11;i++)
{
for(int j=10-i;j>0;j--)
{
cout<<" ";
}
for(int k=1;k<=2*i-1;k++)
{
cout<<"%";
}
for(int m=10-i;m>0;m--)
{
cout<<" ";
}
cout<<"\n";
}
for(int n=9;n>0;n--)
{
for(int x=1;x<=10-n;x++)
{
cout<<" ";
}
for(int y=1;y<=2*n-1;y++)
{
cout<<"%";
}
for(int z=1;z<=10-n;z++)
{
cout<<" ";
}
cout<<"\n";
}
return 0;
}
//=================================== //EX0207.cpp //边长为10的字符菱形 //=================================== #include<iostream> #include<string> using namespace std; //----------------------------------- int main() { for(int i=1 , j=1; i<=19; ++i,j=i<10?i:20-i) cout<<stringe(10-j, ' ')+string(2*j-1,'%')<<'\n'; }//==================================