Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- void SelSort(int a[], int size)
- {
- int i, j, temp, min;
- for(i = 1; i <= size; i++)
- {
- min = a[i];
- for(j = i+1; j <= size; j++)
- {
- if(min > a[j])
- {
- temp = min;
- min = a[j];
- a[j] = temp;
- }
- }
- a[i] = min;
- }
- }
- int main()
- {
- int i, j, a[50], size;
- cout << "Enter the size : ";
- cin >> size;
- for(i = 1; i <= size; i++)
- {
- cout << "\nEnter element " << i << " : ";
- cin >> a[i];
- }
- SelSort(a, size);
- cout << "\nSorted array : ";
- for(i = 1; i <= size; i++)
- {
- cout << a[i] << "\t";
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement