Maze project
#include <stdio.h> void bubble_sort(long[], long); int main() { int array[100], c, d, swap; int n = 0; printf("------Welcome to Bubble Sort Program-------\n"); while (n < 2 || n>=20) { printf("Please enter how many numbers you want to sort (up to 20):\n\t"); scanf("%ld", &n); if(n<2) printf("Since you have fewer than two numbers, they are already sorted!\n"); else if (n>=20) printf("Please enter number less than 20!\n"); } printf("Enter %ld integers\n", n); for (c = 0; c < n; c++) { scanf("%ld", &array[c]); printf("Please enter the next number : \n\t"); } bubble_sort(array, n); printf("Here are the results:\n"); for (c = 0; c < n; c++) printf("%ld\n", array[c]); return 0; } void bubble_sort(long list[], long n) { long c, d, t; for (c = 0; c < (n - 1); c++) { for (d = 0; d < n - c - 1; d++) { if (list[d] > list[d + 1]) { /* Swapping */ t = list[d]; list[d] = list[d + 1]; list[d + 1] = t; } } } }