크리스마스 글자 별찍기 만들어왔다
17번(wjd918273)
2019-12-24 15:35
추천 6
![viewimage.php?id=3dafdf21f7d335ab67b1d1&no=24b0d769e1d32ca73ded85fa11d028314c091b806630224048cd6cbd1352c69c3cfdd2408a0fb980b64adf1e405d3126b84c6daef03e6c21e3c9c6a41f11fb38c8d2f9b62075]()
이건 추가. char brush = '*'; 부분 바꾸면 됨ㅋㅋ
![viewimage.php?id=3dafdf21f7d335ab67b1d1&no=24b0d769e1d32ca73ded85fa11d028314c091b806630224048cd6cbd1352c69c3cfdd2408a0fb980b64adf1e405d3126b84c6daef03e6c21e3c9c2a01917fa3b66b9e2b099ea]()
#include <stdio.h>
#define WIDTH 80
int storeArray(int[][WIDTH
], int, char);
typedef struct alphabet {
char text
;
int width
;
int pixel
;
}alphabet
;
const alphabet alphabetList
[26] = { {'a', 4, 0x699f99}, {'b', 4, 0xe9e99e}, {'c', 4, 0x698896}, {'d', 4, 0xe9999e}, {'e', 4, 0xf8e88f}, {'f', 4, 0xf8e888},
{'g', 4, 0x698b96}, {'h', 4, 0x99f999}, {'i', 3, 0x3a497}, {'j', 4, 0x111996}, {'k', 4, 0x9aca99}, {'l', 4, 0x88888f},
{'m', 5, 0x23bac631}, {'n', 4, 0x99db99}, {'o', 4, 0x699996}, {'p', 4, 0xe99e88}, {'q', 5, 0x19294a4f}, {'r', 4, 0xe99e99},
{'s', 4, 0x694296}, {'t', 5, 0x3e421084}, {'u', 4, 0x99999f}, {'v', 4, 0x999996}, {'w', 5, 0x2318d6aa}, {'x', 4, 0x996999},
{'y', 5, 0x23151084}, {'z', 4, 0xf1248f}};
int main() {
char brush
= '*';
char text
= 0;
int offset
= 0;
while (text
!= EOF) {
int buffer
[6][WIDTH
] = { 0, };
while (1) {
if (!text
)
text
= getchar();
if (text
== '\n') {
offset
= 0;
text
= 0;
break;
}
offset
= storeArray(buffer
, offset
, text
);
if(offset
!= -1)
text
= 0;
else {
offset
= 0;
break;
}
}
for (int i
= 0; i
< 6; i
++) {
for (int j
= 0; j
< WIDTH
; j
++) {
if (buffer
[i
][j
])
printf("%c", brush
);
else
printf(" ");
}
printf("\n");
}
}
}
int storeArray(int arr
[][WIDTH
], int offset
, char text
) {
alphabet alpha
;
if (text
< 'a')
text
+= 32;
if (text
!= ' ')
alpha
= alphabetList
[text
- 'a'];
else
alpha
.width
= 0;
int newOffset
= offset
+ alpha
.width
+ 1;
if (newOffset
<= WIDTH
) {
for (int i
= 0; i
< 6; i
++) {
for (int j
= 1; j
<= alpha
.width
; j
++) {
arr
[5 - i
][newOffset
- j
- 1] = alpha
.pixel
& 0x1;
alpha
.pixel
>>= 1;
}
}
return newOffset
;
}
else
return -1;
}
}자고일어나니 누가 먼저 해놨던데
언어 다르니까 아무튼ㅇㅇ
숫자나 문장부호는 귀찮아서 안넣음
스페이스바 관련사항 수정
가독성이 넘 별루에요
ㅇㅇ; 전각문자로 하려다가 그러면 또 2바이트씩 잡아야되고 해서 존나귀찮아서 안함ㅋㅋ
브러쉬를 *말고 m같은걸로 바꾸면 더 잘보이네
해당 댓글은 삭제되었습니다.
이정도면 만족스럽지않음? 개행도 해줌ㅋㅋ
근데 실수한게 스페이스바 처리를 딱히 안해줬는데 다른환경에서 돌리면 에러나겠네
먼 원리임?
한줄마다 쓸 버퍼 배열을 만듬. 글자 입력받을때마다 글자마다 저장해둔 별 찍을 위치를 그 배열에 갖다박음. 한줄 꽉차면 출력해
글자 위치 저장은
http://m.dcinside.com/board/programming/1209253
요롷게함 - dc Cpp
ㄷㄷ개천재
올 깔끔하네