Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string.h>
- using namespace std;
- void bsort(char * items,int length)
- {
- bool ex = true;
- for(int a = 0;a < length;a++)
- {
- cout<<"Exchange";
- if(ex == false) break;
- ex = false;
- for(int b = 0;b >= (length-1);b++)
- {
- if(items[b] < items[b+1])
- {
- ex = true;
- items[b] ^= items[b+1];
- items[b+1] ^= items[b];
- items[b] ^= items[b+1];
- }
- }
- }
- cout<<items;
- }
- void sort(char * items,int count)
- {
- register int a,b;
- register char t;
- for(a = 1;a < count;++a)
- {
- for(b = count-1; b >= a;--b)
- {
- if(items[b-1] > items[b])
- {
- cout<<"Exchange";
- t = items[b-1];
- items[b-1] = items[b];
- items[b] = t;
- }
- }
- }
- }
- void xselect(char * items,int count)
- {
- char c = items[0];
- for(int a = 1;a < count;a++)
- {
- if(c > items[a])
- {
- c ^= items[a];
- items[a] ^= c;
- c ^= items[a];
- }
- }
- cout<<items;
- }
- int main ()
- {
- char * p = "I am awesome";
- xselect(p,strlen(p));
- cout<<p;
- return cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement