Simple vector odreing question

I tried to make a program that order the numbers in a vector, but after I insert the values from keyboard, nothing happens. Can you please help me?

#include <iostream>
using namespace std;
int vect[100],n;
void order_vector(int v[100],int n){
int i,t=0;
for(i=1;i<n;i++){
if (v[i]<v[i-1]){
t=v[i];
v[i]=v[i-1];
v[i-1]=t;
}
}
}
void show_vector(int v[100]){
for(int i=0;i<n;i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
void create_vector(int v[100],int lenght){
for(int i=0;i<lenght;i++){
cout<<"vector["<<i<<"]=";
cin>>v[i];
}
}
void main(){
int n;
cin>>n;
create_vector(vect,n);
order_vector(vect,n);
show_vector(vect);
cin>>n;
}
Oh dear, nothing is not much...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
using namespace std;
int vect[100]; // Note no n here
void order_vector(int v[100],int n){
int i,t=0;
for(i=1;i<n;i++){
if (v[i]<v[i-1]){
t=v[i];
v[i]=v[i-1];
v[i-1]=t;
}
}
}
void show_vector(int v[100],int n){ // Note place the n here
for(int i=0;i<n;i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
void create_vector(int v[100],int lenght){
for(int i=0;i<lenght;i++){
cout<<"vector["<<i<<"]=";
cin>>v[i];
}
}
void main(){
int n;
cin>>n;
create_vector(vect,n);
order_vector(vect,n);
show_vector(vect,n); // and here
cin>>n;
} 
The ordering is not really working though
Topic archived. No new replies allowed.