[try Beta version]
Not logged in

 
BubbleSort

Pages: 123
Nov 8, 2016 at 3:19am
Yes
Nov 8, 2016 at 3:21am
What is the meaning difference between snap and swap?

"Yes" does not answer this question. This is a Wh- question.
Nov 8, 2016 at 3:28am
I think your teacher meant "swap".
Nov 8, 2016 at 3:28am
Swap is the when you swap the numbers but snap is the bubble sort
Nov 8, 2016 at 3:30am
Have you written your function main?
Nov 8, 2016 at 3:30am
Your function said "void swap()"??
Nov 8, 2016 at 3:32am
I thought that was it .
Nov 8, 2016 at 3:33am
Have you written your function main?
Nov 8, 2016 at 3:35am
what is that ??
Nov 8, 2016 at 3:36am
You don't even know the function main()?
Nov 8, 2016 at 3:43am
nevermind ! i know what you talking about . Just forget it becuase Im not going to get it right . So it dont even matter
Nov 8, 2016 at 3:44am
So what is your next problem?
Nov 8, 2016 at 3:46am
Thats what I trying to figure what i need to do and where to begin
Nov 8, 2016 at 3:47am
And your original assignment? The more detailed the better.
Nov 8, 2016 at 3:49am
Thats the original assignmenet
Nov 8, 2016 at 3:50am
That's the original assignmenet

Your assignment is to write a function main()?
Nov 8, 2016 at 3:53am
The original function is to a function that performs a snap for the numbers array
Nov 8, 2016 at 3:55am
1
2
3
4
5
6
7
8
9
void swap(int &x, int &y, int t = 0) {t = x, x = y, y = t;}

void bubbleSort(int arr[], int size)
{
    int i, j;
    for(i = 0; i < size; i++) 
    for(j = 0; j < size - 1; j++) 
    if(arr[j] > arr[j+1]) swap(arr[j], arr[j+1]);
}
Nov 8, 2016 at 4:02am
The original function is to a function that performs a snap for the numbers array

Presumably, you mean the original function is a function that performs a swap for the numbers array. Such a function is convenient to have in order to facilitate the creation of a sorting function (such as one that implements the bubblesort algorithm.)

Boxbird is right in that the original function is broken. I would verify that you've reproduced it correctly (because I'm fairly certain you have not.)

Nov 8, 2016 at 4:09am
I was going on what my teacher gaves us . He was like put in Visual Studio and it should run but I was thinking something isnt right and it is missing some things
Pages: 123