Beautiful triangulation [simulation]

Description–

X students in order to improve relations small and small C students, specifically to find some lovely picture as a gift.
This is some of the most beautiful graphics of endless triangles, these graphic highly aesthetic small X students would like to achieve, but none had as a preliminary pseudo-retired players, he is limited, so this arduous task It falls upon you.
Since the kind of person topic, the data range n <= 10.
(See specific examples pattern, each pattern stage are made on the three first-order pattern makes up)


Input–

Only one line, the input is an integer N, N represents the order of the required pattern.

Output–

The corresponding output pattern.


Sample Input–

3
2
1

Sample Output–

Here Insert Picture Description


Notes -

10 test points, n is 1-10


Code -

#include<iostream>
#include<cstdio>
using namespace std;
int n,e[10]={1,2,4,8,16,32,64,128,256,512};
string a[1025];
int main()
{
	a[1023]=" /\\ ";
	a[1024]="/__\\";
	scanf("%d",&n); 
	for (int i=2;i<=n;++i)
	{
		for (int j=1024-2*e[i-1]+1;j<=1024-e[i-1];++j)
		{
			for (int k=1;k<=e[i-1];++k)
			  a[j]=' '+a[j];
			a[j]=a[j]+a[j+e[i-1]];
			for (int k=1;k<=e[i-1];++k)
			  a[j]+=' ';
		}
	    for (int j=1024-e[i-1]+1;j<=1024;++j)
		  a[j]=a[j]+a[j];
		  
	}
	for (int i=1024-2*e[n-1]+1;i<=1024;++i)
	  cout<<a[i]<<endl; 
	
	return 0;
}

Guess you like

Origin blog.csdn.net/qq_43654542/article/details/90722575