Anasayfa > Kodlar > C++ ile Adam Asmaca oyunu

C++ ile Adam Asmaca oyunu

Kelimeeri size arttırabilirsiniz..yada memory den yer yememek için bi data base oluşturup ordan rastgele alabilirsiniz..

#include <iostream>
#include <string>
#include<stdlib.h>
#include<time.h>
#include<conio.h>
using namespace std;
using std::string;

int main()
{
string array[26]={"computer","agnostic","anemi a","bannisters","doormat","sho ulder","percentage","consumpti on","fishmonger","psychologist ","programmer","millipede","he dgehog","tangerine","watermelo n","lumbago","jaundice","const ipated","contagious","dysenter y","devious","boastful","swimt ruck","pullover","thunderstorm ","satellite"};
char array2[7];
char choice,char1;
int i,j,count=0,count1=0,flag=0,si ze=0,count2=0;

srand(time(NULL));

j=rand()%26;

for (i=0;array[j][i]!='';i++)
size++;

char *array1;

array1=new char[size];

for (i=0;i<size;i++)
array1[i]='X';

cout << "\t\t\t------------------------------------" << endl;
cout << endl;
cout << "\t\t\tWelcome to Furkan's Hangman Game!!!!" << endl;
cout << endl;
cout << "\t\t\t------------------------------------" << endl;
cout << endl;

while (1)
{
flag=0;

cout << "\t\t\tEntered Characters=";
for (i=0;i<count2;i++)
cout << array2[i] << " ";
cout << endl;

if (count>=0)
cout << "\n\t\t\t ---------------" << endl;
if (count>=1)
cout << "\t\t\t O" << endl;
if (count==2)
cout << "\t\t\t |" << endl;
if (count==3)
cout << "\t\t\t /|" << endl;
if (count==4)
cout << "\t\t\t /|> " << endl;
if (count==5)
{
cout << "\t\t\t /|> " << endl;
cout << "\t\t\t / " << endl;
}

cout << endl;
cout << "\t\t\t-------------------------" << endl;
cout << endl;
cout << "\t\t\t";
for (i=0;i<size;i++)
cout << array1[i];
cout << endl;
cout << endl;

cout << "\t\t\tplease enter a character=";
cin >> char1;

array2[count2]=char1;
count2++;

system("cls");

for (i=0;i<size;i++)
{
if (char1==array[j][i])
{
array1[i]=array[j][i];
count1++;
flag=1;
}
}
if (flag==0)
count++;

if (count1==size)
{
cout << "\t\t\tYou found right Word:" << array[j] << "!!!\n" << endl;
cout << "\t\t\tTebrikleeeeerrrr!!! YOU WON!!!\n" << endl;
cout << "\t\t\tPlay again?(Y or N)=";
cin >> choice;
if (choice=='Y' || choice=='y')
{
size=0;
j=rand()%26;

for (i=0;array[j][i]!='';i++)
size++;
for (i=0;i<size;i++)
array1[i]='X';
count=0;
count1=0;
}
if (choice=='N' || choice=='n')
break;
}

if (count==6)
{
cout << "\t\t\tRight Word:" << array[j] << "!!!\n" << endl;
cout << "\t\t\tSorry! YOU LOST!!!\n" << endl;
cout << "\t\t\tPlay again?(Y or N)=";
cin >> choice;
if (choice=='Y' || choice=='y')
{
size=0;
j=rand()%26;

for (i=0;array[j][i]!='';i++)
size++;

for (i=0;i<size;i++)
array1[i]='X';
count=0;
count1=0;
}
if (choice=='N' || choice=='n')
break;
}
}
return 0;
}

Reklamlar
Kategoriler:Kodlar Etiketler:, , , ,
  1. betül
    09/04/2014, 22:39

    bisuru hata var

    Beğen

  1. No trackbacks yet.

Bir Yanıt Bırakın

Aşağıya bilgilerinizi girin veya oturum açmak için bir simgeye tıklayın:

WordPress.com Logosu

WordPress.com hesabınızı kullanarak yorum yapıyorsunuz. Log Out / Değiştir )

Twitter resmi

Twitter hesabınızı kullanarak yorum yapıyorsunuz. Log Out / Değiştir )

Facebook fotoğrafı

Facebook hesabınızı kullanarak yorum yapıyorsunuz. Log Out / Değiştir )

Google+ fotoğrafı

Google+ hesabınızı kullanarak yorum yapıyorsunuz. Log Out / Değiştir )

Connecting to %s

%d blogcu bunu beğendi: