[HDU] [2091] Hollow Triangle

Problem Description

Loading...

Problem Analysis

A rather interesting pattern-printing problem
Just pay attention to the output format

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include<stdio.h>
int main() {
	char c;
	bool flag=false;
	while(scanf("%c",&c),c!='@') {
		if(flag)
			printf("\n");
		flag=true;
		int n;
		scanf("%d",&n);
		getchar();
		int t=-1;
		for(int i=0; i<n; i++) {
			t++;
			for(int j=1; j<=n+t; j++) {
				if(i==n-1||j==n+t||j==n-t)
					printf("%c",c);
				else
					printf(" ");
			}
			printf("\n");
		}
	}
	return 0;
}

Problem link: [HDU] [2091] Hollow Triangle

Loading...