Untitled

mail@pastecode.io avatar
unknown
c_cpp
7 months ago
792 B
5
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("%c", &tahmin);
		int temp = 0;
		for (int i = 0; i < strlen(kelime); i++)
		{
			if (tahmin == kelime[i])
			{
				printf("Gardas: %c", 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