Solved

Need Help With A Program

Posted on 2000-04-01
5
195 Views
Last Modified: 2010-04-02
Hello all,

I'm making a program, in Visual Studio 6.0, that will do the following:

-Bubble Sort 100 Random Strings
-Show the original and sorted strings
-Be able to show both the decending and ascending sort results
-and use an array string

If you can whip up a program that does this, I will be very happy.

I also have access to Borland Compiler 5, and DJGPP if you are more comfortable with does.

Again Thank You.
0
Comment
Question by:jc2048
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2676808
Why don't you try this yourself and post what you get done.  Then we can make suggestions.  You will learn much more that way.
0
 

Expert Comment

by:PKothari
ID: 2677570
I can tell u the logic.
If u can write program and post it back
on the site if u encounter any problems then we can solve it.

Here's the logic

Display a menu
1.Ascending
2.Descending.
Use 2 dimensional arrays.
if(ascending)
{
  Get the 100 strings.
  Store them in 2 arrays.
  Start comparing.
  for(i=0;i<100;i++)
   {
    for(j=i+1;j<100;j++)
    {
     if(strcmp(a[i],a[j]))
      {
       temp=a[i];//temp-->temprorary variable
        a[i]=a[j]  //swap the numbers
        a[j]=temp;
      }
    }
  }
}
same in the case for descending only the if condition changes.

While displaying as u have 2 arrays one the original and other sorted u can display both of them
I think this solves u r problem
       
   
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2677690
See as good example
http://www.snippets.org/strsort.c
0
 
LVL 1

Accepted Solution

by:
ZivKatzir earned 50 total points
ID: 2720197
Hi,
the idea behind bubble sort is quit simple :
 1. loop through all variables of the
    array.
 2. for every item perform check
    your condition.
 3. swap the two items if needed
 4. save the position of the last swaped
    argument.

the loop described above will make the
appropriate item (i.e. largest or smallest) be positioned in the last place of the array.

Now, repeate the proccess described above until no swaps were made. Each time scan the array to the position of the previusly saved position of the last swap (there is no need to compare variables positioned beyond the last swap since they are already in the correct order).

That's it, if still want a source code
I will write down some for you.
 
0
 
LVL 22

Expert Comment

by:nietod
ID: 2720291
Its probably safe to assume that a question that hasn't got activity for 2 weeks is a dead question and not in need of answering.   Its also very likely that this is a school assignment, and thus it is a violation of EE's accademic policy to provide a complete answer to it.
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question