English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

how do i create a Microsoft Visual C++ program that would use sequential sorting if i want to display the numbers defined by any user in ascending order and bubble sorting if the user wants to display the numbers in descending order?

2007-02-04 18:32:56 · 4 answers · asked by Don M 1 in Computers & Internet Programming & Design

4 answers

check out http://www.pscode.com for great sample codes.

2007-02-04 18:54:57 · answer #1 · answered by Richard H 7 · 0 0

You're probably having problems getting into the situation where you can compile C, as Visual C++ is more set up for C++. Having started Visual Studio select File, New, Project. Then in the templates find Visual C++ (different installs will have it in different places). Now select "Win32 Console Application" and click OK. The Win32 Application wizard will fire up, click Next to get to the second page and uncheck "Precompiled header", if you don't do that you'll need to #include "stdafx.h" at the start of every source. Click Finish to get into the project. Make sure you have a running application now, try the Build and Debug menus to make sure you understand how you work with the project. The wizard will have created a .cpp file with a _tmain entry point. Because the file name ends .cpp it is a C++ source. To create a true C program you need to rename this .cpp to .c, click on file name in the solution explorer on the right side; click on the .cpp file in the Solution Explorer, press F2 to rename the file and delete the pp from .cpp. You can now paste your program over the source and you're all set to go...

2016-05-24 14:54:38 · answer #2 · answered by Anonymous · 0 0

Don't use a bubble sort. It is the second slowest sort there is. (The only slower one that I know of is the serial search sort.)
Even the shell sort in Kerningham and Ritchie's C manual is almost reasonable. It is 4-5 lines of code so even if you duplicate it for ascending and descending it is quite reasonable to use.
Note: You can usually get rid of the slow divide by 2 with a bitwise right-shift >>

2007-02-04 18:44:30 · answer #3 · answered by J C 5 · 0 0

Here are a couple of good websites to check out.
http://www.codeproject.com
http://www.codeguru.com
I am sure if you searched those sites, you will find a bunch of sorting algorithims.
They usually distribute both the executable file and the source files.
You probably have to register in order to download, but it is free.

2007-02-04 18:44:24 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers