[c] heiko
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- /**********************************************************************\
- * Kurzbeschreibung: Übung 16.1
- *
- * Datum: Autor: Grund der Aenderung:
- * 12.02.21 Heiko Kastner
- *
- \**********************************************************************/
- /*--- #includes ------------------------------------------------------*/
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- //#include <cstdlib.h>
- #include <ctype.h>
- /*--- #defines -------------------------------------------------------*/
- /*--- typedef-Datentypen ---------------------------------------------*/
- /*--- Funktionsdefinitionen ------------------------------------------*/
- int main()
- {
- int z,y,i;
- i= 0;
- printf("Zunaechst musst du einmal festlegen, wie gross die zu ratende Zahl \n"
- "maximal sein darf:\n");
- //Belegung der Variable//
- if (scanf("%d",&z) == 1){
- int t = rand () % (z + 1); //Generieren des Zufallswertes mit z+1 -----> Null ausgeschlossen//
- printf("Hm ..... OK, ich habe eine Zahl%d\n", t);
- do
- {
- // Hochzählen der Rateversuche
- fflush(stdin);
- i+=1;
- printf("Dein %d. Versuch:",i);
- scanf("%d",&y);
- if(y < t)
- printf(" .....zu niedrig \n"); // Fehlerbedingungen für zu groß und zu klein
- else if
- (y > t)
- printf(" ........zu hoch \n");
- }
- while(y!= t);
- }
- else{
- printf("Ungueltige Eingabe !!\n");
- return 0;
- }
- printf(" ........richtig \n");
- printf("Du hast %d. Versuche zum erraten der Zahl benoetigt\n",i);
- return 0;
- }
Editor
You can edit this paste and save as new:
File Description
- heiko
- Paste Code
- 12 May-2021
- 1.88 Kb
You can Share it:
Latest Code Pastes