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