Monday, May 24, 2010

C++ program?

You will implement the BubbleSort Algorithm. You will perform the sort on an array of 100 randomly generated integers ranging from 0 to 1000. Your program should print out the initial array and then finally the sorted array. so can you write it in c++

C++ program?
OK, it's been over 20 years since I had this freshman CS exercise, so I'll write you the sort routine because, believe it or not, it's fun.





void BubbleSort(int *pNumArray)


{


for(int i = 1; i %26lt; 100; i++)


for(int j = i; j %26gt; 0; j--)


{


if(pNumArray[j] %26lt; pNumArray[j-1])


{


int nTemp = pNumArray[j];


pNumArray[j] = pNumArray[j-1];


pNumArray[j-1] = nTemp;


}


}


}





// Now, I hope we've learned a lot.
Reply:You want to somebody write this program instead of you ??? :)) LOL it not will happen :) i can say one advice: try to write yourself and ask if u stuck somewhere... but not in this way :) Good luck to your homework.....


i think i don`t get the "best answer" to my reply :)))
Reply:hahah I wish I had this when I was in school. Hey you will not be good if you cant get simple sort algorithms like this down. Its called trail and error good luck
Reply:The question is "Can you write it in C++". My answer is "Yes, I can".


No comments:

Post a Comment