c++ 행맨만드는중입니다. 소스좀 봐주세요 너무 답답합니다.

iphone의 이미지

#include
#include
#include
using namespace std;

int main()
{
char answer,typing;
srand((unsigned) time(NULL));
int a=rand()%52;
int wrong=0, score=0;
char alpha[10]={'_','_','_','_','_','_','_','_','_','\0'};
string words[] =
{
"ball", "book", "train", "bike", "rain", "car", "truck", "boat", "plane", "baby",
"spoon", "shoes", "shirt", "pants", "hat", "star", "flower", "house", "tree", "brush",
"towel", "chair", "table", "bed", "blanket", "light", "cookie", "cheese", "apple", "banana",
"candy", "milk", "juice", "water", "dog", "cat", "fish", "bird", "duck", "cow",
"horse", "bear", "pig", "lion", "elephant", "zebra", "monkey", "chicken", "butterfly", "bee",
"frog", "snake"
};
for(;;)
{
cout << words[a]<<"\n";
system("cls");
switch(words[a].size())
{
case 3:
cout << alpha << "\b\b\b\b\b\b"<<" (3글자 입니다)"< break;
case 4:
cout << alpha << "\b\b\b\b\b"<<" (4글자 입니다)"< break;
case 5:
cout << alpha << "\b\b\b\b"<<" (5글자 입니다)"< break;
case 6:
cout << alpha << "\b\b\b"<<" (6글자 입니다)"< break;
case 7:
cout << alpha << "\b\b" <<" (7글자 입니다)"< break;
case 8:
cout << alpha << "\b" << " (8글자 입니다)"< break;
case 9:
cout << alpha <<" (9글자 입니다)" << endl;
break;
}


switch(wrong)
{
case 1:
cout << "\n\n\n\n\n\n\n-+----\n";
break;

case 2:
cout << "\n |\n |\n |\n |\n |\n |\n-+----\n";
break;

case 3:
cout << "\n +---\n |\n |\n |\n |\n |\n |\n-+----\n";
break;

case 4:
cout << "\n +---\n | |\n |\n |\n |\n |\n |\n-+----\n";
break;

case 5:
cout << "\n +---\n | |\n | O\n |\n |\n |\n |\n -+----\n";
break;

case 6:
cout << "\n +---\n | |\n | O\n | |\n | |\n |\n |\n -+----\n";
break;

case 7:
cout << "\n +---\n | |\n | O\n | -|\n | |\n |\n |\n-+----\n";
break;

case 8:
cout << "\n +---\n | |\n | O\n | -|-\n | |\n |\n |\n-+----\n";
break;

case 9:
cout << "\n +---\n | |\n | O\n | -|-\n | |\n | /\n |\n-+----\n";
break;

case 10:
cout << "\n +---\n | |\n | O\n | -|-\n | |\n | //\n |\n-+----\n";
break;

}


cout << "알파벳을 입력하시오 : ";
cin >> typing;
if(typing>=65 && typing<=90)
typing=typing+32;

if(typing==words[a][0] && alpha[0] == '_'){
score++;
alpha[0]=typing;
}
if(typing==words[a][1]&& alpha[1] == '_'){
score++;
alpha[1]=typing;
}
if(typing==words[a][2]&& alpha[2] == '_')
{
score++;
alpha[2]=typing;
}
if(words[a].size()>=4 && typing==words[a][3]&& alpha[3] == '_')
{
score++;
alpha[3]=typing;
}

if(words[a].size()>=5 && typing==words[a][4]&& alpha[4] == '_')
{
score++;
alpha[4]=typing;
}

if(words[a].size()>=6 && typing==words[a][5]&& alpha[5] == '_')
{
score++;
alpha[5]=typing;
}
if(words[a].size()>=7 && typing==words[a][6]&& alpha[6] == '_')
{
score++;
alpha[6]=typing;
}
if(words[a].size()>=8 && typing==words[a][7]&& alpha[7] == '_')
{
score++;
alpha[7]=typing;
}
if(words[a].size()>=9 && typing==words[a][8]&& alpha[8] == '_')
{
score++;
alpha[8]=typing;
}


if(!(typing==words[a][0]
|| typing==words[a][1]
|| typing==words[a][2]
|| (words[a].size()>=4 && typing==words[a][3])
|| (words[a].size()>=5 && typing==words[a][4])
|| (words[a].size()>=6 && typing==words[a][5])
|| (words[a].size()>=7 && typing==words[a][6])
|| (words[a].size()>=8 && typing==words[a][7])
|| (words[a].size()>=9 && typing==words[a][8]) ) )
wrong++;



if(score == words[a].size() )
{

cout << "정답입니다\n";

cout << "계속하시겠습니까? (y/n) : ";
cin >> answer;

if(answer=='y')
{
srand((unsigned) time(NULL));
a=rand()%52;
for(int i=0; i<9; i++)
{
alpha[i]='_';
}
wrong=0, score=0;
continue;
}
else if(answer=='n')
break;
}

if(wrong==10)
{
cout<<"다시하시겠습니까?(y/n)";
cin >> answer;
if(answer=='y')
{score = 0;
continue ;
}
else if(answer=='n')
break;
}
}

return 0;
}

이게 소스입니다.

제가 제일 궁금한점은 랜덤단어의 마지막 타이핑을 입력했을때 빈칸이 안채워지는점과
해당단어가 다틀려서 그림10번이 안띄워지는점입니다.

File attachments: 
첨부파일 크기
Image icon c2.JPG99 KB
Image icon c.JPG107.22 KB
Image icon 없음.JPG85.87 KB
pchero의 이미지

일단... 올려주신 소스에 문법 오류가 많이 있어 컴파일이 되지 않습니다.
어떻게 실행하신 건가요?

테스트하신 소스랑 올려주신 소스랑 내용이 다른건가요?

---------------------------------
제일 왼쪽이 저입니다 :)

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.