Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream
- using namespace std;
- void BubbleSort (int V[], int a)
- int i, k;
- for (i = 0; i < m; ++i)
- {
- for (j = 0; j < m-i-1; ++k)
- {
- if (V[k] > V[k+1])
- {
- V[k] = V[k]+V[k+1];
- V[k+1] = V[k]-V[k + 1];
- V[k] = V[k]-V[k + 1];
- }
- }
- }
- }
- int main()
- {
- int m, i;
- cout<<"Introdu nr-ul de date pe care urmează să le sortez ";
- cin>>a;
- int V[m];
- for(i = 0; i < m; i++)
- {
- cout<<"Introdu element "<<i+1<<": ";
- cin>>V[i];
- }
- BubbleSort(V, a);
- cout<<"Datele sortate sunt ";
- for (i = 0; i < m; i++)
- cout<<"->"<<V[i];
- return 0;
- }
Add Comment
Please, Sign In to add comment