Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > C/C++ программирование > Visual C++
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 29.04.2013, 23:54   #1
Veiner
Новичок
Джуниор
 
Регистрация: 29.04.2013
Сообщений: 1
По умолчанию Виселица на с++

есть код игры виселица, но он не работает, хотя ошибок не находит(
#include "stdafx.h"
#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
#include <cstdio>


using namespace std;

char guess;
int wordnum;
int thesize;
string theword;
void DisplayUnderscores (int size);
void ScanForLetter (string word,char letter,int size);


void Intro ()
{
cout << " ................................... ................................... ........" << endl;
cout << " ....##.....##....###....##....##..# #####......##.....##....###....##.. ..##...." << endl;
cout << " ....##.....##...##.##...###...##.## ....##.....###...###...##.##...###. ..##...." << endl;
cout << " ....##.....##..##...##..####..##.## ...........####.####..##...##..#### ..##...." << endl;
cout << " ....#########.##.....##.##.##.##.## ...####....##.###.##.##.....##.##.# #.##...." << endl;
cout << " ....##.....##.#########.##..####.## ....##.....##.....##.#########.##.. ####...." << endl;
cout << " ....##.....##.##.....##.##...###.## ....##.....##.....##.##.....##.##.. .###...." << endl;
cout << " ....##.....##.##.....##.##....##..# #####......##.....##.##.....##.##.. ..##...." << endl;
cout << " ................................... ................................... ........" << endl << endl;

cout << "\t _____ " << endl;
cout << "\t | / | " << endl;
cout << "\t |/ " << endl;
cout << "\t | " << endl;
cout << "\t | " << endl;
cout << "\t | " << endl;
cout << "\t__|________ " << endl;
}


void Intro1 ()
{
cout << " ................................... ................................... ........" << endl;
cout << " ....##.....##....###....##....##..# #####......##.....##....###....##.. ..##...." << endl;
cout << " ....##.....##...##.##...###...##.## ....##.....###...###...##.##...###. ..##...." << endl;
cout << " ....##.....##..##...##..####..##.## ...........####.####..##...##..#### ..##...." << endl;
cout << " ....#########.##.....##.##.##.##.## ...####....##.###.##.##.....##.##.# #.##...." << endl;
cout << " ....##.....##.#########.##..####.## ....##.....##.....##.#########.##.. ####...." << endl;
cout << " ....##.....##.##.....##.##...###.## ....##.....##.....##.##.....##.##.. .###...." << endl;
cout << " ....##.....##.##.....##.##....##..# #####......##.....##.##.....##.##.. ..##...." << endl;
cout << " ................................... ................................... ........" << endl << endl;

cout << "\t _____ " << endl;
cout << "\t | / | " << endl;
cout << "\t |/ O " << endl;
cout << "\t | " << endl;
cout << "\t | " << endl;
cout << "\t | " << endl;
cout << "\t__|________ " << endl;
}


int main()
{
srand(time(0));


wordnum = rand() % 10 + 1;

switch (wordnum)
{
case 1:
theword = "rhythm"; break;
case 2:
theword = "lynx"; break;
case 3:
theword = "photosynthesis"; break;
case 4:
theword = "uncopyrightable"; break;
case 5:
theword = "hospitalisation"; break;
case 6:
theword = "fly"; break;
case 7:
theword = "sky"; break;
case 8:
theword = "sync"; break;
case 9:
theword = "onomatopoeia"; break;
case 10:
theword = "satyr"; break;
}

thesize = theword.length();

Intro();

DisplayUnderscores(thesize);

cout << endl << endl << "\tGuess a letter: ";
cin >> guess;

ScanForLetter(theword , guess , thesize);


system ("PAUSE");
return 0;
}

void DisplayUnderscores (int size)
{

char *Array = new char[size];

Array[size];

for (int p = 0; p<size; p++)
{
Array[p] = '_';
}

cout << endl << "\t" << " ";

for (int p = 0; p<size; p++)
{
cout << Array[p] << " ";
}

}

void ScanForLetter (string word,char letter,int size)
{

//int size = word.length();

for (int i = 0 ; i < size ; i++)
{

//IF LETTER IS CORRECT ################################### ################################### ###############
if (word[i] == letter)
{

}

//if letter is INCORRECT ################################### ################################### ###############
if(word[i] != letter)
{

}
}

}
Veiner вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
игра виселица ilnar4ik18 Помощь студентам 0 28.04.2013 14:08
Игра "Виселица" на Delphi 7 Veterok0587 Помощь студентам 0 12.05.2010 14:53
программа "виселица" в Basic инопланетянка Помощь студентам 0 03.03.2010 19:38
помогите составить игру "Виселица" Ymka Помощь студентам 1 23.11.2009 19:06