Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Chaozhk

Bubble Sort with C Programming

This topic is 5223 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can someone help me write a C program about bubble sorting 10 integers using arrays?? plz help me, i just started using arrays and can''t quite understand it. Plz help me write the program. thanks

Share this post


Link to post
Share on other sites
Advertisement
Sounds like homework.

Besides, I betcha Google can help. Google knows all. (Even the incorrect stuff!)

[Edit - I don't mean to be a prick or anything, but it does sound like homework. If not, though, then I suppose I could help if you ask a more specific question. Otherwise, I'd just recommend looking on the internet for some tutorials, since the bubble sort is probably the easiest to learn, and there is probably plenty of info out there already. No use in duplicating it all the time.]

[edited by - Agony on June 2, 2004 11:29:15 AM]

Share this post


Link to post
Share on other sites
quote:
From the forum FAQ
9) Do not ask homework related questions. The GameDev.net members are not here to answer your homework questions, its against the forum rules and few people take kindly to it. Besides, we shouldn’t need to tell you that figuring it out for yourself will be way more beneficial to you in the long run.


I'm guessing this must be a homework question because I don't understand why anyone in their right mind would want to write a bubblesort implementation for any kind of real life application.

If you have a more specific question relating to exactly which bit you are having problems understanding, then ask it - but don't expect anyone to do your homework for you.

Also, Google is your friend.

[edited by - Sandman on June 2, 2004 11:34:29 AM]

Share this post


Link to post
Share on other sites
#include <stdio.h>
#define Size 10
void swap(int*, int*);
void bubbleSort(int[], int);
main()
{
int i, list[Size] = {32, 11, 62, 45, 89, 23, 18, 31, 54, 29};
bubbleSort(list,Size);
printf("After Sorting: \n");
for(i=0; i printf("%4d", list);
printf("\n");
system("PAUSE");
}

i only can do the integers when it is given, but how to make the computer get the inputted integers and arrange them?

Share this post


Link to post
Share on other sites
You might try looking up the function scanf(). It''s very much like printf() but gets input, as opposed to displaying output. After that, the easy way is to simply read in a number, which would be Size, and then read in that many more integers, which are stored in your array.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!