Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.0 kB
3
Indexable
Never
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

#define MAX_MISTAKE 3

struct Tahmin
{
    int index;
    char ch;
};

int main()
{
    char a[3][20] = {"balina", "havlu", "mars"};
    struct Tahmin tahminler[6];
    char tahmin;
    int tahmin_sayisi = 0;
    int mistake = 0;
    char *kelime = a[1];

    while (mistake <= 3)
    {
        printf("Bir harf girin:");
        scanf("\n%c", &tahmin);
        int temp = 0;
        for (int i = 0; i < strlen(kelime); i++)
        {
            if (tahmin == kelime[i])
            {
                printf("Gardas: %c\n", tahmin);
                tahminler[tahmin_sayisi].index = i;
                tahminler[tahmin_sayisi].ch = tahmin;
                tahmin_sayisi++;
                temp++;
            }
        }
        if (temp == 0)
        {
            mistake++;
            printf("Yanlis tahmin. Kalan hakkiniz: %d\n", MAX_MISTAKE - mistake);
        }
        else
        {
            temp = 0;
        };
    }
}
Leave a Comment