C++ 특수문자열 질문드립니다.

tekuph의 이미지

안녕하세요.
C++로 오목을 제작하려고 합니다.!
깔끔하게 만들고 싶어서 특수문자를 특수문자를 통해서
만들었는데 먼가 홀쭉하게 나오길래 특수문자열 사이에 공백을 집어 넣엇더니
제가 원하는대로 출력되더라고요.
그런데 오목이면 돌을 두어야 하는데 스트링 자체에서 지원하는
리플레이스나 엣같은것을 써보아도 별로 화면이 글자가 깨지거나 오목판이 밀려서 출력되던데
안꺠지게 출력하는 방법이 있을까요?! ○●
특수문자를 넣고 사이즈 오브를 돌려봣는데 먼가 "" '' 이거 바꿔도 한바이트는 차이나고
엄청 어렵던데 어떻게 해야 할지 감이 안잡히내요.

File attachments: 
첨부파일 크기
Image icon 오목판.PNG29.91 KB
Image icon 31233312313.PNG11.29 KB
shint의 이미지

윈도우용 - 콘솔 그래픽 함수를 사용하는 방법도 있습니다.
https://drive.google.com/drive/folders/0B_788O9A9oekR1NzVWZ0b0p4YTg?usp=sharing
그 밖에. 폰트나 Draw 함수를 사용하여 자간을 지정할 수 있지만. 복잡할겁니다.
글자 간격을 처리하는 이미 만들어진 프로그램이나 컨트롤도 있겠지만. 확인해봐야 합니다.

http://codepad.org/wUdhaAqj

#include <iostream>
#include <stdio.h>
#include <string>
 
using namespace std;
 
int main()
{
    int i=0;
    int j=0;
 
    char a[10][10];
 
    for(i=0; i<10; i++)
    {
        for(j=0; j<10; j++)
        {
            a[i][j] = '.';
        }
    }
 
    a[3][3] = 'X';
    a[5][3] = 'X';
    a[6][6] = 'X';
    a[4][5] = 'O';
 
    for(i=0; i<10; i++)
    {
        for(j=0; j<10; j++)
        {
            printf("%c", a[i][j]);
        }
        printf("\n");
    }
 
 
    for(i=0; i<10; i++)
    {
        for(j=0; j<10; j++)
        {
            if(a[i][j] == 'X' || a[i][j] == 'O')
            {
                printf("%c", a[i][j]);
            }
            else
            {
                if(i==0 && j== 0) //왼쪽 위
                {
                    printf("┌");
                }
                else if ((i>=1 && i< 9) && j==0) //왼쪽
                {
                    printf("├");
                }
                else if (j>=1 && j< 9 && i==0) //위에 중간
                {
                    printf("┬");
                }
                else if ((i>=1 && i< 9) && (j>=1 && j< 9)) //중간 중간
                {
                    printf("┼");
                }
                else if(j == 9 && i == 0) //오른쪽 위
                {
                    printf("┐");
                }
                else if(j == 9 && (i>=1 && i< 9)) //오른쪽
                {
                    printf("┤");
                }
                else if(i==9 && j== 0) //왼쪽 아래
                {
                    printf("└");
                }
                else if(i==9 && (j>=1 && j< 9)) //아래쪽 중간
                {
                    printf("┴");
                }
                else if(i==9 && j== 9) //오른쪽 아래
                {
                    printf("┘");
                }
            }
        }
        cout << endl;
    }
 
    //추가로 특수문자나 한글은 3byte를 사용하기도 합니다.
    string s = "ㅁㅁㅁ";
    char * t = (char*) s.c_str();
    //http://hashcode.co.kr/questions/88/stdstring%EC%9D%84-const-char%EB%82%98-char%EB%A1%9C-%EB%B0%94%EA%BE%B8%EB%8A%94-%EB%B0%A9%EB%B2%95
    printf("%c%c%c\n", t[0], t[1], t[2]);
 
    //추가로 printf() 의 출력 위치 정렬하는 방법은
    printf("%10d\n", 10);
    printf("%10c\n", 'A');
    printf("%-10d\n", 10);
    printf("%-10c\n", 'B');
    return 0;
}

..........
..........
..........
...X......
.....O....
...X......
......X...
..........
..........
..........
┌┬┬┬┬┬┬┬┬┐
├┼┼┼┼┼┼┼┼┤
├┼┼┼┼┼┼┼┼┤
├┼┼X┼┼┼┼┼┤
├┼┼┼┼O┼┼┼┤
├┼┼X┼┼┼┼┼┤
├┼┼┼┼┼X┼┼┤
├┼┼┼┼┼┼┼┼┤
├┼┼┼┼┼┼┼┼┤
└┴┴┴┴┴┴┴┴┘

10
A
10
B

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.