C_C++

(C언어) 알파벳 삼각형 모양 출력하기

고니자니 2022. 11. 8. 19:19
반응형

알파벳 삼각형 모양 출력하기 1

#include <stdio.h>

int main()
{
	int i, j;
	for (i = 0; i < 26; i++)
	{
		for (j = 0; j <= i; j++)
			printf("%c", 'A' + j);
		printf("\n");
	}
}

(Output)

A
AB
ABC
ABCD
ABCDE
ABCDEF
ABCDEFG
ABCDEFGH
ABCDEFGHI
ABCDEFGHIJ
ABCDEFGHIJK
ABCDEFGHIJKL
ABCDEFGHIJKLM
ABCDEFGHIJKLMN
ABCDEFGHIJKLMNO
ABCDEFGHIJKLMNOP
ABCDEFGHIJKLMNOPQ
ABCDEFGHIJKLMNOPQR
ABCDEFGHIJKLMNOPQRS
ABCDEFGHIJKLMNOPQRST
ABCDEFGHIJKLMNOPQRSTU
ABCDEFGHIJKLMNOPQRSTUV
ABCDEFGHIJKLMNOPQRSTUVW
ABCDEFGHIJKLMNOPQRSTUVWX
ABCDEFGHIJKLMNOPQRSTUVWXY
ABCDEFGHIJKLMNOPQRSTUVWXYZ

(C언어) 알파벳 삼각형 모양 출력하기

 

알파벳 삼각형 모양 출력하기 2

#include <stdio.h>

int main()
{
	int i, j, a='A';
	for (i = 0; i < 6; i++)
	{
		for (j = 0; j <= i; j++)
			printf("%c", a++);
		printf("\n");
	}
}

(Output)

A
BC
DEF
GHIJ
KLMNO
PQRSTU

 

 

반응형