#include<iostream>
using namespace std;
void triangle1(int max);
void triangle2(int max);
void pyramid(int max);
void diamond(int max);
void menu()
{
cout<<"1.삼각형1"<<endl;
cout<<"2.삼각형2"<<endl;
cout<<"3.피라미드"<<endl;
cout<<"4.다이아몬드"<<endl;
}
int main()
{
int n, max=0;
menu();
cout<<"메뉴선택 하시오[1-4].:";cin>>n;
cout<<"출력할 행을 입력하시오.:";cin>>max;
switch(n)
{
case 1:
triangle1(max);
break;
case 2:
triangle2(max);
break;
case 3:
pyramid(max);
break;
case 4:
diamond(max);
break;
}
return 0;
}
void triangle1(int max)
{
for(int y = 1; y <= max; y++)
{
for(int x = 1; x <= y; x++)
{
cout<<"x";
}
cout<<endl;
}
}
void triangle2(int max)
{
for(int y = 1; y <= max; y++)
{
for(int x = 1; x <= max-y; x++)
{
cout<<" ";
}
for(int x = 1; x <= y; x++)
{
cout<<"x";
}
cout<<endl;
}
}
void pyramid(int max)
{
for(int y = 1; y <= max; y++)
{
for(int x = 1; x <= max - y; x++ )
{
cout<<" ";
}
for(int x = 1;x <= (y * 2)-1; x++)
{
cout<<"x";
}
cout<<endl;
}
}
void diamond(int max)
{
for(int y = 1; y <= max; y++)
{
for(int x = 1; x <= max - y; x++ )
{
cout<<" ";
}
for(int x = 1;x <= (y * 2)-1; x++)
{
cout<<"x";
}
cout<<endl;
}
for(int y = max-1; y >= 1; y--)
{
for(int x = max - y; x >= 1; x-- )
{
cout<<" ";
}
for(int x = (y * 2)-1;x >= 1; x--)
{
cout<<"x";
}
cout<<endl;
}
}