huseyinddemirci
Decapat
- Katılım
- 13 Nisan 2023
- Mesajlar
- 26
Daha fazla
- Cinsiyet
- Erkek
Kendi çapımda bir adam asmaca yapıyordum ama birkaç noktada takıldım.
Tahmin edilen harflerin bir diziye kaydedilmesini ve ekrana Denenen Harfler: A B C gibi yazdırılmasını ve denenen harfler tekrar girildiğinde oyuncunun uyarılmasını istiyorum ama bir türlü yapamadım. Şimdiden teşekkürler.
Kod;
Tahmin edilen harflerin bir diziye kaydedilmesini ve ekrana Denenen Harfler: A B C gibi yazdırılmasını ve denenen harfler tekrar girildiğinde oyuncunun uyarılmasını istiyorum ama bir türlü yapamadım. Şimdiden teşekkürler.
Kod;
C++:
#include <iostream>
#include <string>
using namespace std;
string kelime, gizlikelime;
string kelimeler[] = { "BLUE", "ORANGE","RED", "BROWN", "BLACK"};
char tahmin;
int yanlis = 0;
int main()
{
srand(time(0));
int y = rand() % 5;
string kelime = kelimeler[y];
while (gizlikelime.size() !=kelime.size())
{
gizlikelime.push_back('_');
}
do
{
cout << "Bulunan harfler: " << endl;
cout << gizlikelime<<endl;
cout << "Bir harf tahmini yapin: ";
cin >> tahmin;
system("cls");
int x = kelime.length();
for (int i = 0; i < x; i++)
{
if (tahmin == kelime[i]) {
gizlikelime[i] = tahmin;
yanlis--;
}
}
yanlis++;
if (gizlikelime==kelime)
{
cout << "Oyunu kazandiniz." << endl;
break;
}
if (yanlis == 0)
{
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << "Kalan Deneme Hakkiniz: " << "9/"<<(9 - yanlis) << endl;
}
else if (yanlis == 1)
{
cout << " " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "Kalan Deneme Hakkiniz: " << (9 - yanlis) << "/9" << endl;
}
else if (yanlis == 2)
{
cout << " ________ " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "Kalan Deneme Hakkiniz: " << (9 - yanlis) << "/9" << endl;
}
else if (yanlis == 3)
{
cout << " ________ " << endl;
cout << "| | " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "Kalan Deneme Hakkiniz: " << (9 - yanlis) << "/9" << endl;
}
else if (yanlis == 4)
{
cout << " ________ " << endl;
cout << "| | " << endl;
cout << "| ( ) " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "Kalan Deneme Hakkiniz: " << (9 - yanlis) << "/9" << endl;
}
else if (yanlis == 5)
{
cout << " ________ " << endl;
cout << "| | " << endl;
cout << "| ( ) " << endl;
cout << "| | " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "Kalan Deneme Hakkiniz: " << (9 - yanlis) << "/9" << endl;
}
else if (yanlis == 6)
{
cout << " ________ " << endl;
cout << "| | " << endl;
cout << "| ( ) " << endl;
cout << "| | " << endl;
cout << "| / " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "Kalan Deneme Hakkiniz: " << (9 - yanlis) << "/9" << endl;
}
else if (yanlis == 7)
{
cout << " ________ " << endl;
cout << "| | " << endl;
cout << "| ( ) " << endl;
cout << "| | " << endl;
cout << "| / \\ " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "| " << endl;
cout << "Kalan Deneme Hakkiniz: " << (9 - yanlis) << "/9" << endl;
}
else if (yanlis == 8)
{
cout << " ________ " << endl;
cout << "| | " << endl;
cout << "| ( ) " << endl;
cout << "| | " << endl;
cout << "| / \\ " << endl;
cout << "| | " << endl;
cout << "| | " << endl;
cout << "| / " << endl;
cout << "Kalan Deneme Hakkiniz: " << (9 - yanlis) << "/9" << endl;
}
else if (yanlis == 9)
{
cout << " ________ " << endl;
cout << "| | " << endl;
cout << "| ( ) " << endl;
cout << "| | " << endl;
cout << "| / \\ " << endl;
cout << "| | " << endl;
cout << "| | " << endl;
cout << "| / \\ " << endl;
cout << "Kalan Deneme Hakkiniz: " << (9 - yanlis) << "/9" << endl;
cout << "Oyunu kaybettiniz." << endl;
cout << "Gizli Kelime: " << kelime <<endl;
}
} while (yanlis<9);
return 0;
}
Son düzenleyen: Moderatör: