Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int MAX_DIM=100;
- typedef int Vettore[MAX_DIM];
- void leggiVett(Vettore , int &);
- void BubbleSort (Vettore, const int);
- void swap(int &,int &);
- void StampaVettore(const Vettore,const int);
- int main(int argc, char** argv) {
- Vettore vett;
- int riemp;
- int num;
- leggiVett(vett, riemp);
- BubbleSort(vett,num);
- return 0;
- }
- void leggiVett(Vettore v,int & nelem){
- do{
- cout<<"Inserisci il numero di elementi del vettore (max "<<MAX_DIM<<" ) \n";
- cin>>nelem;
- }
- while(nelem>MAX_DIM || nelem<=0);
- cout<<"Inserisci gli elementi del vettore ";
- for(int i=0;i<nelem;i++)
- cin>>v[i];
- }
- void swap(int & a ,int & b){
- int temp;
- temp=a;
- a=b;
- b=temp;
- }
- void BubbleSort(Vettore v, const int nelem){
- for(int i=0;i<nelem;i++) {
- for(int j=0;j<nelem-1;j++)
- if(v[j]>v[j+1]){
- swap(v[j],v[j+1]);
- }
- }
- }
- void StampaVettore(const Vettore v,const int dim){
- cout<<"\nIl vettore risulta : ";
- for(int i=0;i<)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement