Add exercises 09.

This commit is contained in:
2026-06-18 09:03:11 +02:00
parent 21b9b70871
commit 487f103de4
16 changed files with 389 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
#include <time.h>
#include "stoppuhr.h"
static clock_t zeitStempel = 0;
void starteUhr()
{
zeitStempel = clock();
}
double messeZeitInSek()
{
return (double)(clock() - zeitStempel) / CLOCKS_PER_SEC;
}
+7
View File
@@ -0,0 +1,7 @@
#ifndef STOPPUHR_H
#define STOPPUHR_H
void starteUhr();
double messeZeitInSek();
#endif
+29
View File
@@ -0,0 +1,29 @@
#include <stdio.h>
#include "zahlenEingabe.h"
int gibZahlEin()
{
return gibMinMaxZahlEin(0x80000000, 0x7fffffff);
}
int gibMinZahlEin(int min)
{
return gibMinMaxZahlEin(min, 0x7fffffff);
}
int gibMinMaxZahlEin(int min, int max)
{
int zahl, geleseneWerte;
do
{
geleseneWerte = scanf("%d", &zahl);
while(getchar() != '\n') {}
if(geleseneWerte != 1 || zahl < min || zahl > max)
printf("Fehler! Erneute Eingabe: ");
} while(geleseneWerte != 1 || zahl < min || zahl > max);
return zahl;
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef ZAHLEN_EINGABE_H
#define ZAHLEN_EINGABE_H
int gibZahlEin();
int gibMinZahlEin(int min);
int gibMinMaxZahlEin(int min, int max);
#endif
+8
View File
@@ -0,0 +1,8 @@
#include <stdlib.h>
#include "zufallsarray.h"
void fuelleArray(int array[], int anzahl, int min, int max)
{
for(int i = 0; i < anzahl; i++)
array[i] = rand() % (max - min + 1) + min;
}
+6
View File
@@ -0,0 +1,6 @@
#ifndef ZUFALLSARRAY_H
#define ZUFALLSARRAY_H
void fuelleArray(int array[], int anzahl, int min, int max);
#endif