BubbleSort

Pages: 123
Write a function that performs a snap for the numbers array

void swap( int i, int) {
int k;
int l;
i=j
j-k
};

Im just wondering am I on the right track because this all I have so far cause I am stuck
void swap(int &i, int &j) { int t = i; i = j; j = t; };
why t instead of k ?? So, thats all I need for this function because I dont understand programming at all plus my teacher does not explain very well
void swap(int &i, int &j) { int k = i; i = j; j = k; };

Why t instead of k ??

't' stands for "temporary".
So, I was on the right track ???
Not the right track at all.
1
2
3
4
5
6
void swap( int i, int) {
int k;
int l;
i=j
j-k
};

Your code does not even compile.
Last edited on
thats what my teacher gave us and said it should work !
Then how about this?
1
2
3
4
5
6
void swap( int i, int) {
int k;
int l;
i=j
j-k
};

You are missing some semi-colons (;) at the end of the statements.
Last edited on
So this void swap is a array correct ??
So this void swap is an array correct ??

No, not an array. This is not a swap function, but a broken one.
Ugh, I dont know what I am doing. So, what is this then .
What do you want to do with your swap function?
Perform a snap for the numbers array
Perform a snap for the numbers array

What do you mean?
Thats what my teacher told us to do. He said write a function that performs a snap for the numbers array. Then he gave us that little code and said it should work
What do you mean by snap?
Would it be the same as bubblesort
What is the original assignment?
Write a function that performs a snap for the numbers array.
What is the meaning difference between snap and swap?
Pages: 123