vielmax
This commit is contained in:
parent
529e1f6f10
commit
7d8e3180b0
44
vielmax.c
Normal file
44
vielmax.c
Normal file
@ -0,0 +1,44 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int number = 0;
|
||||
int maxNumber = 0;
|
||||
int numbers[100];
|
||||
int count = 0;
|
||||
char input[100];
|
||||
int validInput = 0;
|
||||
|
||||
while (1) {
|
||||
printf("Bitte geben Sie eine Zahl ein (oder 'b' um zu beenden): ");
|
||||
scanf("%s", input);
|
||||
|
||||
if (input[0] == 'b' && input[1] == '\0') {
|
||||
if (count == 0) {
|
||||
printf("Fehler: Keine Zahl eingegeben. Bitte geben Sie mindestens eine Zahl ein.\n");
|
||||
while (getchar() != '\n');
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (sscanf(input, "%d", &number) == 1) {
|
||||
numbers[count++] = number;
|
||||
if (count == 1 || number > maxNumber) {
|
||||
maxNumber = number;
|
||||
}
|
||||
validInput = 1;
|
||||
} else {
|
||||
printf("Ungültige Eingabe. Bitte geben Sie eine gültige Zahl ein.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (validInput) {
|
||||
printf("Eingegebene Zahlen: ");
|
||||
for (int i = 0; i < count; i++) {
|
||||
printf("%d ", numbers[i]);
|
||||
}
|
||||
printf("\nDie größte eingegebene Zahl ist: %d\n", maxNumber);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user