编辑代码

#include <stdio.h>
#include <stdbool.h>

int findMaxValue(int array[], int size) {
    if (size == 0) { 
        printf("Sequence is empty.\n");
        return 0;
    }

    int maxValue = array[0]; 
    for (int i = 1; i < size; i++) {
        if (array[i] > maxValue) {
            maxValue = array[i];
        }
    }

    return maxValue;
}

int main() {
    // 测试用例
    int testCases[][6] = {
        {6, 5, 4, 3, 2, 1},
        {-8, 8, 8, 8}, 
        {}                  
    };
    int testCasesSize[] = {6, 4, 0};

    int numTestCases = sizeof(testCases) / sizeof(testCases[0]);

    for (int i = 0; i < numTestCases; i++) {
        int* sequence = testCases[i];
        int size = testCasesSize[i];

        int maxValue = findMaxValue(sequence, size);

        if (size == 0) {
            continue;
        }

        printf("case %d: [", i + 1);

        for (int j = 0; j < size; j++) {
            printf("%d", sequence[j]);
            if (j != size - 1) {
                printf(", ");
            }
        }

        printf("]\nMax value: %d\n", maxValue);
    }

    return 0;
}