Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- class selection{
- int * ar , size;
- public:
- void getInput();
- void s_sort();
- void display();
- };
- void selection::getInput(){
- cout << "Enter the size of array:\n";
- cin >> size;
- ar = new int[size];
- cout << "Enter the data into array:\t";
- for(int i=0;i<size;i++)
- cin >>ar[i];
- }
- void selection::s_sort(){
- int t;
- for(int k=0; k<size-1; k++)
- for(int m=k+1; m<size; m++)
- if(ar[k] > ar[m]){
- t = ar[k];
- ar[k] = ar[m];
- ar[m] = t;
- }
- }
- void selection::display(){
- cout << "Data of array after sorting = \n";
- for(int i=0;i<size;i++)
- cout << ar[i] << endl;
- }
- int main(){
- selection *s = new selection();
- s->getInput();
- s->s_sort();
- s->display();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement