need to give the number of middle
-
when somebody input some number,you need give out the number of middle.my code is follow:#include using namespace std; void swap(int &a,int &b); void main() { int n=0,k,m,j; int*p=new int[n]; cin>>n; k=n; j=n; m=n; for(;n>0;n--) { cin>>p[n-1]; } int x=1; while(x) { x=0; for(;k>0;k--) { if(p[k-1]
-
when somebody input some number,you need give out the number of middle.my code is follow:#include using namespace std; void swap(int &a,int &b); void main() { int n=0,k,m,j; int*p=new int[n]; cin>>n; k=n; j=n; m=n; for(;n>0;n--) { cin>>p[n-1]; } int x=1; while(x) { x=0; for(;k>0;k--) { if(p[k-1]
youbo wrote:
the number of middle.
AKA the median.
youbo wrote:
my code is follow
Congratulations. :rolleyes:
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
youbo wrote:
the number of middle.
AKA the median.
youbo wrote:
my code is follow
Congratulations. :rolleyes:
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
when somebody input some number,you need give out the number of middle.my code is follow:#include using namespace std; void swap(int &a,int &b); void main() { int n=0,k,m,j; int*p=new int[n]; cin>>n; k=n; j=n; m=n; for(;n>0;n--) { cin>>p[n-1]; } int x=1; while(x) { x=0; for(;k>0;k--) { if(p[k-1]
Here you go
void swap(int &a,int &b); void main() { int array_size=0,k,m,j; cin>>array_size; if(array_size < 1) return; int*p=new int[array_size]; for(int i=0;i>p[i]; } // Lets do a bubble sort bool changed = true; int bubble_end = array_size - 1; while(changed) { changed = false; for(int i=0;i p[i+1]) { swap(p[i],p[i+1]); changed = true; } } } if(array_size > 1) { if(array_size%2==1) cout< -- modified at 8:50 Saturday 15th September, 2007
-
Here you go
void swap(int &a,int &b); void main() { int array_size=0,k,m,j; cin>>array_size; if(array_size < 1) return; int*p=new int[array_size]; for(int i=0;i>p[i]; } // Lets do a bubble sort bool changed = true; int bubble_end = array_size - 1; while(changed) { changed = false; for(int i=0;i p[i+1]) { swap(p[i],p[i+1]); changed = true; } } } if(array_size > 1) { if(array_size%2==1) cout< -- modified at 8:50 Saturday 15th September, 2007
-
Is dash space dash exclamation exclamation an abbreviation for something?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
thank you first,but i couldn't find out the differences from your code to mine.i have run it ,it appeared the same wrong that is not i need. my code in the same with yours is looked right....
Look more closely
void main() { int n=0,k,m,j; **//n is Zero so you declare an array of zero size !** int*p=new int[n]; **// To late you update the value of n** cin>>n; k=n; j=n; m=n; for(;n>0;n--) { cin>>p[n-1]; } int x=1; while(x) { x=0; for(;k>0;k--) { **// This syntax is just wrong try to understand rather than just getting it to compile** if(p[k-1] { swap(p[k-1],p[k]); x=1; } } } **// What if only one element is enter opps were off the end of the array** if(m%2==1){cout<get this,it is also wrong.please have