Windows 7 64bit / Visual Studio 2013 Express
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
int height = -1;
int lineNumber = 0;
int numberPrint = 1;
int variation = 1;
int mid = 0;
int numberCount = 0;
printf_s("Input height : ");
scanf_s("%d", &height);
for (int heightCount = 1; heightCount < height; heightCount++)
{
numberCount = 0;
numberPrint = heightCount;
for (int spaceCount = 0; spaceCount < height - heightCount; spaceCount++)
{
printf_s(" ");
numberCount++;
}
for (int widthCount = 0; widthCount < (heightCount * 2) - 1; widthCount++)
{
if (numberPrint >= 10)
{
numberPrint = numberPrint % 10;
}
else if (numberPrint < 0)
{
numberPrint = 9;
}
mid = (heightCount * 2) - 1;
printf_s("%d", numberPrint);
numberCount++;
if (numberCount >= height)
{
variation = -1;
}
numberPrint += variation;
}
printf_s("\n");
variation = 1;
}
return 0;
}
Output
[C언어 연습문제] 알파벳 피라미드 (0) | 2014.06.04 |
---|---|
[C언어 연습문제] 별로 사선 채우기 (0) | 2014.06.04 |
Windows Console Command TREE 를 구현해보자 (0) | 2014.05.27 |