Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- void bubbleSort(char arr[], int x)
- {
- int i, j, bufor;
- for(i = 0; i < x - 1; i++)
- {
- for(j = 0; j < x - 1 - i; j++)
- {
- if(arr[j] > arr[j + 1])
- {
- bufor = arr[j];
- arr[j] = arr[j + 1];
- arr[j + 1] = bufor;
- }
- }
- }
- }
- int main()
- {
- int n = 100;
- char arr[n];
- int i;
- srand(time(NULL));
- for(i = 0; i < n; i++)
- {
- arr[i] = (rand() % 26) + 65;
- }
- for(i = 0; i < n; i++)
- {
- printf("%c", arr[i]);
- }
- printf("\n\n");
- bubbleSort(arr, n);
- for(i = 0; i < n; i++)
- {
- printf("%c", arr[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement