Add exercises 09.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef STOPPUHR_H
|
||||
#define STOPPUHR_H
|
||||
|
||||
void starteUhr();
|
||||
double messeZeitInSek();
|
||||
|
||||
#endif
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef ZUFALLSARRAY_H
|
||||
#define ZUFALLSARRAY_H
|
||||
|
||||
void fuelleArray(int array[], int anzahl, int min, int max);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user