View Code of Problem 2592

#include<stdio.h>
#include<string.h>
int main() {
	int n,i,num,j,j1,k,f;
	char x;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		getchar();
		scanf("%c %d",&x, &num);

		k = 0;
		for (j = 0; j < num; j++) {
			
			if (j != num - 1) {
				for (j1 = 0; j1 < num - j-1; j1++) {
					printf(" ");
				}
				printf("%c", x);
				if (k != 0) {
					for (j1 = 0; j1 < k; j1++) {
						printf(" ");
					}
					printf("%c", x);
				}
				if (j == 0) {
					k = k + 1;
				}
				else {
					k = k + 2;
				}

			}
			else {
				for (j1 = 0; j1 < num * 2 - 1; j1++) {
					printf("%c", x);
				}
			}
			printf("\n");
			

		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 2592