Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
#include <stdio.h>
#include <string.h>
#include <conio.h>
typedef unsigned short int usint;
int main()
{
printf("Hangman Deluxe \n\n");
const usint max_breite = 20, max_err = 10;
char ergebnis[max_breite];
const char wort[max_breite] = "Deutschland";
usint i,laenge=strlen(wort),error=0;
bool solved = false,OK = false;
for(i=0; i<laenge; i++)
//Ergebnis mit _ füllen
ergebnis[i] = '-';
ergebnis[i] = '\0';
printf("%s - Fehler: %d von %d\n",ergebnis,error,max_err);
while (error != max_err && !solved)
{
OK = false;
//Benutzereingabe.....
char eingabe[max_breite];
scanf("\n%s",eingabe);
if (strlen(eingabe) == 1)
{
for(i = 0; i < laenge; i++)
{
if (wort[i] == eingabe[0])
{
ergebnis[i] = eingabe[0];
OK = true; // Buchstabe gefunden
}
}
if (!OK) error++;
else if (strncmp(wort,ergebnis,max_breite) == 0) solved = true;
}
else {
if (strncmp(wort,eingabe,max_breite) == 0) solved = true;
else error++;
}
//Ausgabe
if (solved) printf("Richtig !\n\n");
else printf("%s - Fehler: %d von %d\n",ergebnis,error,max_err);
}
printf("Game Over");
getch();
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
int hangman()
{
char input;
char temp[12];
char word[][20] = {"bil","cykel", "hammare", "nyckel",
"hem", "afrika", "nolla", "nummer", "adress", "efter",
"final", "igen", "nu",
"folk", "jag", "du", "allihop", "vem",
"olika", "alltid"};
srand((unsigned)time(NULL));
int k = (rand() % 20);
int i = 0;
int r = 0;
char b[]= "*********";
int length = strlen(word[k]);
int turn = 7;
int dummy = 0;
int decide = 0;
printf("so many letters you have.\n");
for(i = 0; i < length; i++)
{
printf("%c", b[i]);
}
while(turn != 0)
{
printf("\nTurns left: ");
printf("%d", turn);
printf("\nEnter a letter to guess: ");
input = getchar();
while(getchar() != '\n');
// printf(" %s.\n", word[k]);
for(r = 0; r < length; r++)
{
if(input == word[k][r]) //om bokstaven är rätt
{
decide = 1;
printf("%c", word[k][r]);
}
if(input != word[k][r]) //om bokstaven är fel
{
decide = 0;
printf("*");
}
}
if(decide == 0)
{
turn--;
}
for(r = 0; r < length; r++)
{
if(input == word[k][r])
{
b[r] = word[k][r];
temp[r] = word[k][r];
temp[length] = '\0';
// printf("%c", b[r]);
}
}
}
if(strcmp(temp, word[k]) == 0)
{
printf("%c", word[k][r]);
}
if(strcmp(temp, word[k]) != 0)
{
printf("\nSorry, no more turns left. The secret word was %s.\n", word[k]);
}
else
{
printf("\nCongratulations!\nYou guessed the secret word: %s\n", word[k]);
}
return 0;
}
int main(void)
{
printf("Welcome to HANGMAN\n");
printf("You will be asked to guess the computer's secret word.\n");
printf("The word will be displayed as a number of *'s. Every time\n");
printf("you guess a letter correctly, that letter will be shown in its\n");
printf("correct position in the word. If you guess incorrectly, the\n");
printf("number of tries you have left will be decremented. You will be\n");
printf("given a maximum of 7 incorrect guesses.\n\n");
hangman();
return 0;
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
int hangman()
{
char input;
char word[][20] = {"bil","cykel", "hammare", "nyckel",
"hem", "afrika", "nolla", "nummer", "adress", "efter",
"final", "igen", "nu",
"folk", "jag", "du", "allihop", "vem",
"olika", "alltid"};
srand((unsigned)time(NULL));
int k = (rand() % 20);
int i = 0;
int length = strlen(word[k]);
int turn = 7;
int hit = 0;
printf("so many letters you have.\n");
char raten[length];
for(i = 0; i < length; i++)
{
raten[i] = '*';
printf("%c", raten[i]);
}
raten[i] = '\0';
while(turn != 0)
{
printf("\nTurns left: ");
printf("%d", turn);
printf("\nEnter a letter to guess: ");
input = getchar();
while(getchar() != '\n');
//printf(" %s.\n", word[k]);
for(i = 0; i < length; i++)
{
if(input == word[k][i] && input != raten[i]) //om bokstaven är rätt
{
hit = 1;
raten[i] = input;
}
printf("%c", raten[i]);
}
if(hit == 0)
{
turn--;
}
else
{
hit = 0;
if(strcmp(raten, word[k]) == 0)
{
printf("\nCongratulations!\nYou guessed the secret word: %s\n", word[k]);
break;
}
}
}
if (turn == 0)
{
printf("\nSorry, no more turns left. The secret word was %s.\n", word[k]);
}
return 0;
}