Guest User

Untitled

a guest
Mar 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream
  2.  
  3.  
  4.  
  5.  
  6. using namespace std;
  7.  
  8.  
  9.  
  10. void BubbleSort (int V[], int a)
  11.  
  12.  
  13.  
  14. int i, k;
  15.  
  16. for (i = 0; i < m; ++i)
  17.  
  18. {
  19.  
  20.  
  21.  
  22.  
  23. for (j = 0; j < m-i-1; ++k)
  24. {
  25.  
  26. if (V[k] > V[k+1])
  27. {
  28. V[k] = V[k]+V[k+1];
  29.  
  30.  
  31.  
  32.  
  33. V[k+1] = V[k]-V[k + 1];
  34.  
  35.  
  36.  
  37.  
  38.  
  39. V[k] = V[k]-V[k + 1];
  40. }
  41. }
  42.  
  43. }
  44. }
  45.  
  46.  
  47. int main()
  48. {
  49.  
  50.  
  51. int m, i;
  52.  
  53.  
  54.  
  55. cout<<"Introdu nr-ul de date pe care urmează să le sortez ";
  56.  
  57.  
  58. cin>>a;
  59.  
  60.  
  61.  
  62. int V[m];
  63.  
  64. for(i = 0; i < m; i++)
  65.  
  66. {
  67. cout<<"Introdu element "<<i+1<<": ";
  68.  
  69.  
  70.  
  71. cin>>V[i];
  72.  
  73. }
  74.  
  75. BubbleSort(V, a);
  76.  
  77.  
  78.  
  79.  
  80. cout<<"Datele sortate sunt ";
  81.  
  82.  
  83.  
  84. for (i = 0; i < m; i++)
  85.  
  86.  
  87.  
  88. cout<<"->"<<V[i];
  89.  
  90.  
  91.  
  92. return 0;
  93. }
Add Comment
Please, Sign In to add comment