BULME-6ABELI / 6ABELI_MuminHadzic

You are viewing an older revision! See the latest version

Homepage

Table of Contents

  1. Spiel Kalt oder Heiß

Spiel Kalt oder Heiß

include the mbed library with this snippet

#include <iostream>
#include "time.h"
using namespace std;
int main()
{
    time_t now;
    time_t final;
    double seconds;
    int Eingabe;
    int ZahlFix;
    int Versuche=0;

    cout << "Geben Sie ein Zahl ein: ";
    cin >> ZahlFix;
    system("CLS");
    if (ZahlFix >= 1 && ZahlFix <= 10)
    {
        time(&now);
        do
        {
            
            cout << "Versuchen Sie jetzt:";
            cin >> Eingabe;
            Versuche++;
            if (Eingabe+1 == ZahlFix|| Eingabe - 1 == ZahlFix)
            {
                cout << "Falsch! Heiss!" << endl << endl;
            }
            else if (Eingabe+2 == ZahlFix || Eingabe - 2 == ZahlFix)
            {
                cout << "Falsch! Warm!" << endl << endl;
            }
            else if (Eingabe == ZahlFix)
            {
                time(&final);
                seconds = difftime(final, now);
                cout << endl << "Genau ! Zeit: " << seconds << " sekunden" << endl << "Versuche: " << Versuche << endl;
            }

            else
            {
                cout << "Falsch! Kalt!" << endl << endl;
            }
        } while (Eingabe != ZahlFix);

    }

    else
    {
        cout << "Wahlen Sie ein Zahl zwichen 1 und 10!"<<endl;
    }
}

All wikipages