환경 : Windows 7 64bit / Visual Studio 2013 Express
#include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { int width = -1; int height = -1; int gap = -1; printf_s("Input Width : "); scanf_s("%d", &width); printf_s("Input Height : "); scanf_s("%d", &height); printf_s("Input Gap : "); scanf_s("%d", &gap); int gapPrint = 0; for (int printCount = 0; printCount < height * width; printCount++) { if ((printCount % width) == 0) { printCount++; printf_s("\n"); for (int gapCount = gapPrint; gapCount < gap; gapCount++) { printf_s(" "); } if (gapPrint == gap) { gapPrint = 0; } else { gapPrint++; } } printf_s("*"); for (int gapCount = 0; gapCount < gap; gapCount++) { if ((printCount % width) == 0) { printf_s("\n"); } printf_s(" "); } } return 0; }
Output
[C언어 연습문제] 숫자 피라미드 (1) | 2020.01.20 |
---|---|
[C언어 연습문제] 알파벳 피라미드 (0) | 2014.06.04 |
Windows Console Command TREE 를 구현해보자 (0) | 2014.05.27 |