#include <stdio.h>
#include <string.h>

#define SIZE 15
#define NAME_SIZE 50

void bubbleSort(char towns[][NAME_SIZE],
                int size)
{
    for (int pass = 0; pass < size - 1; ++pass)
    {
        int swapped = 0;

        for (int i = 0; i < size - 1 - pass; ++i)
        {
            if (strcmp(towns[i], towns[i + 1]) > 0)
            {
                char hold[NAME_SIZE];

                strcpy(hold, towns[i]);
                strcpy(towns[i], towns[i + 1]);
                strcpy(towns[i + 1], hold);

                swapped = 1;
            }
        }

        if (swapped == 0)
        {
            break;
        }
    }
}

int main(void)
{
    char towns[SIZE][NAME_SIZE] =
    {
        "Cairo",
        "Alexandria",
        "Giza",
        "Luxor",
        "Aswan",
        "Port Said",
        "Suez",
        "Tanta",
        "Mansoura",
        "Minya",
        "Fayoum",
        "Damietta",
        "Ismailia",
        "Hurghada",
        "Sharm El Sheikh"
    };

    bubbleSort(towns, SIZE);

    printf("Towns in alphabetical order:\n");

    for (int i = 0; i < SIZE; ++i)
    {
        printf("%s\n", towns[i]);
    }

    return 0;
}