C++语言输出以*组成的三角形
#include <iostream.h>
#define length 5
void main()
{
int i, j;
for ( i = 1; i <= length; i ++ ) // ×óÈý½Ç
{
for ( j = 1; j <= i; j++ )
{
//if()
// {
cout << \"*\";
// }
}
cout << endl;
}
cout << endl;
for ( i = 1; i <= length; i ++ ) // µ¹×óÈý½Ç
{
for ( j = 0; j <= length - i; j++ )
{
cout << \"*\" ;
}
cout << endl;
}
cout << endl;
for ( i = 1; i <= length; i ++ ) //ÓÒÈý½Ç
{
for ( j = 1; j <= length; j++ )
{
if( j > length - i )
cout << \"*\" ;
else
cout << \" \";
}
cout << endl;
}
cout << endl;
for ( i = 1; i <= length; i ++ ) //µ¹ÓÒÈý½Ç
{
for ( j = 1; j <= length; j ++ )
{
if( j >= i )
cout << \"*\" ;
else
cout << \" \";
}
cout << endl;
}
cout << endl;
}