Test2
This commit is contained in:
parent
4194fc9686
commit
8af445cbc5
@ -1,17 +1,18 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int main() {
|
||||
int vielmax(int count, ...);
|
||||
int vielmax(int count, ...) {
|
||||
va_list args;
|
||||
va_start(args, count);
|
||||
|
||||
int max = va_arg(args, int);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (int i = 1; i < count; i++) {
|
||||
int num = va_arg(args, int);
|
||||
if (num>max) {
|
||||
max = num;
|
||||
} else if (num == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end(args);
|
||||
@ -22,16 +23,16 @@ int main() {
|
||||
printf("Testprogramm fuer Funktion vielmax ()");
|
||||
printf("=====================================\n\n");
|
||||
|
||||
//int max1 = vielmax(6, 12, 17, 3, 6, 24, 8);
|
||||
//printf("Das Maximum der Zahlen 12, 17, 3, 6, 24, 8: %d", max1);
|
||||
|
||||
|
||||
int max2 = vielmax(5, 1, 11, 33, 12, 9);
|
||||
printf("Das Maxiumum der Zahlen 1, 11, 33, 12, 9: %d", max2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Created by Lennart Pecher on 04.04.25.
|
||||
//
|
||||
//
|
||||
// Created by Lennart Pecher on 04.04.25.
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user