Advertisement
Guest User

qwe

a guest
Jan 24th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_DIM=100;
  5. typedef int Vettore[MAX_DIM];
  6. void leggiVett(Vettore , int &);
  7. void BubbleSort (Vettore, const int);
  8. void swap(int &,int &);
  9. void StampaVettore(const Vettore,const int);
  10. int main(int argc, char** argv) {
  11.    
  12.     Vettore vett;
  13.     int riemp;
  14.     int num;
  15.     leggiVett(vett, riemp);
  16.     BubbleSort(vett,num);
  17.    
  18.     return 0;
  19. }
  20.  
  21. void leggiVett(Vettore v,int & nelem){
  22.     do{
  23.    
  24.         cout<<"Inserisci il numero di elementi del vettore (max "<<MAX_DIM<<" ) \n";
  25.         cin>>nelem;
  26. }
  27.     while(nelem>MAX_DIM || nelem<=0);
  28.    
  29.     cout<<"Inserisci gli elementi del vettore ";
  30.     for(int i=0;i<nelem;i++)
  31.     cin>>v[i];
  32.    
  33.    
  34.     }
  35.    
  36. void swap(int & a ,int & b){
  37. int temp;
  38. temp=a;
  39. a=b;
  40. b=temp;
  41.  
  42. }
  43.    
  44. void BubbleSort(Vettore v, const int nelem){
  45.    
  46.     for(int i=0;i<nelem;i++) {
  47.         for(int j=0;j<nelem-1;j++)
  48.         if(v[j]>v[j+1]){
  49.             swap(v[j],v[j+1]);
  50.         }
  51.     }
  52. }
  53.  
  54. void StampaVettore(const Vettore v,const int dim){
  55.  
  56.     cout<<"\nIl vettore risulta : ";
  57.     for(int i=0;i<)
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement