Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. // Bibliotheken
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include <stdlib.h>
  5.  
  6. // Deklaration der Funktionen
  7. int zahl_eingabe();
  8. int ascii_strichmaenchen(int zahl);
  9.  
  10. // Mainfunktion
  11. int main()
  12. {
  13.     int z[3], versuchszaehler; // Array für die Eingabe von Zahl 1-4
  14.        
  15.     z[0] = zahl_eingabe(); // Eingabe Zahl Eins verweist auf Funktion zahl_eingabe()
  16.     z[1] = zahl_eingabe(); // Eingabe Zahl Zwei verweist auf Funktion zahl_eingabe()
  17.     z[2] = zahl_eingabe(); // Eingabe Zahl Drei verweist auf Funktion zahl_eingabe()
  18.  
  19.            
  20.     versuchszaehler = 0; // Versuchszähler auf Null setzten
  21.            
  22.             do {
  23.              
  24.                 if (versuchszaehler < 1)
  25.                 {
  26.                     printf("Bitte geben Sie eine Zahl zwischen 1 und 9 ein.\n");
  27.                 }
  28.                
  29.                 else
  30.                 {
  31.                     printf("Sie haben eine falsche Zahl eingeben!\nBitte geben Sie nur Zahlen ein die kleiner als 10 und groesser als 0 sind!\nBitte wiederholen Sie daher die Eingabe!\n%i. Versuch\n", versuchszaehler + 1);
  32.                 }
  33.                
  34.                 scanf("%i", &z[3]);
  35.                
  36.                
  37.                 versuchszaehler = versuchszaehler + 1;
  38.            
  39.             } while(z[3] > 9 || z[3] < 1);
  40.            
  41.             system("cls");
  42.            
  43.             printf("%i <- 1, %i <- 2, %i <- 3, %i <- 4\n", z[0], z[1], z[2], z[3]);
  44.            
  45.             ascii_strichmaenchen(0);
  46.             getch();
  47.            
  48.            
  49. }
  50.  
  51. //Funktion zur Eingabe der ersten drei Zahlen!
  52. int zahl_eingabe()
  53. {
  54.     int eingabe;
  55.    
  56.     printf("Bitte geben Sie eine beliebige Zahl ein.\n");
  57.     scanf("%i", &eingabe);
  58.     system("cls");
  59.    
  60.     return eingabe;
  61. }
  62.  
  63. int ascii_strichmaenchen(int zahl)
  64. {
  65.     printf("    %i%i%i%i\n", zahl, zahl, zahl, zahl);
  66.     printf("    %i%i%i%i\n", zahl, zahl, zahl, zahl);
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement