Submission

Status:
-----

Score: 0

User: Pera

Problemset: หินงอก

Language: c

Time: 0.001 second

Submitted On: 2024-10-03 14:55:37

#include <stdio.h>

int main(void) {

    int rocks;
    printf("Input number of stalactite : ");
    scanf("%d", &rocks);
    int height[rocks + 10000];
    int max_height = 0;
    //Store rock heights
    for (int i = 0; i < rocks; i++) {
        scanf("%d", &height[i]);
        if (max_height < height[i]) max_height = height[i];
    }

    //Loop each row
    for (int row = 0; row < max_height; row++) {
        //Loop each rocks
        for (int j = 0; j < rocks; j++) {
            //Loop print the opening
            for (int k = height[j] - 1; k >= 0 ; k--) {
                row == height[j] - 1 - k ? printf("\\") : printf(" ");
            }
            //Loop print the closing
            for (int k = 0; k < height[j]; k++) {
                row == height[j] - 1 - k ? printf("/") : printf(" ");
            }
        }
        printf("\n");
    }

}