hallo
This commit is contained in:
parent
6c8d9d7286
commit
529e1f6f10
38
hallo.c
38
hallo.c
@ -1,2 +1,36 @@
|
|||||||
sophia
|
#include <stdio.h>
|
||||||
Bora
|
|
||||||
|
int main() {
|
||||||
|
int max_zahlen, i, eingabe;
|
||||||
|
|
||||||
|
printf("Gib ein wie viele Zahlen verglichen werden sollen: ");
|
||||||
|
if (scanf("%d", &max_zahlen) != 1) {
|
||||||
|
printf("Ungueltige Eingabe, bitte eine ganze Zahl eingeben.\n");
|
||||||
|
while (getchar() != '\n');
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int zahlen[max_zahlen];
|
||||||
|
|
||||||
|
for (i = 0; i < max_zahlen; i++) {
|
||||||
|
printf("Gib eine Zahl ein: ");
|
||||||
|
if (scanf("%d", &eingabe) != 1) {
|
||||||
|
printf("Ungueltige Eingabe, bitte eine ganze Zahl eingeben.\n");
|
||||||
|
while (getchar() != '\n');
|
||||||
|
i--;
|
||||||
|
} else {
|
||||||
|
zahlen[i] = eingabe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int max = zahlen[0];
|
||||||
|
for (i = 1; i < max_zahlen; i++) {
|
||||||
|
if (zahlen[i] > max) {
|
||||||
|
max = zahlen[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Das Maximum der Zahlen ist: %d\n", max);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user