C++ arrays, sorting

This is a discussion on C++ arrays, sorting within the C++ Programming forums, part of the General Programming Boards category; I have to write a C++ program that will sort an array, check for duplicates, and delete the duplicates: i.e: ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    12

    C++ arrays, sorting

    I have to write a C++ program that will sort an array, check for duplicates, and delete the duplicates:
    i.e: a[0]='a', a[1]='b', a[2]='a', a[3]='c'. After sorting, I would have:
    a[0]='a', a[1]='b', a[2]='c'.

    I can load the array and have found several examples of how to sort, but cannot find out how to compare as well as change the array size or index. Any help would be appreciated.

    Thanks.

    Kyle.

  2. #2
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    Posts
    196
    1) learn dynamic memory allocation (new, delete)
    2) use the vector header file (the vector class) thats the easy way out... ;x
    nextus, the samurai warrior

  3. #3
    looking for the truth moemen ahmed's Avatar
    Join Date
    Feb 2002
    Location
    Egypt
    Posts
    161
    I have to write a C++ program that will sort an array, check for duplicates, and delete the duplicates
    elements of a an array couldnt be deleted because th size of an array is fixed (thats why nextus recommended vectors,as its size could change dynamically in run time) )
    Programming is a high logical enjoyable art for both programer and user !!

  4. #4
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    Posts
    196
    yes...but please do learn what the vector class (header file) is doing because its very important...dynamic memory allocation is no joke!
    nextus, the samurai warrior

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 06-11-2009, 11:27 AM
  2. Sorting Arrays
    By DaniiChris in forum C Programming
    Replies: 11
    Last Post: 08-03-2008, 08:23 PM
  3. Replies: 16
    Last Post: 01-01-2008, 03:07 PM
  4. Replies: 2
    Last Post: 02-23-2004, 05:34 AM
  5. sorting arrays
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 10-13-2001, 05:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21