Really struggling with this problem!

Ok guys, I was given an assignment, and I am running into a lot of problems with coding this.

#include <string>
using namespace std;
int listdistinct( string b[], int n );
// modifies b so that all the distinct values are in b[0..k-1] and returns k
// the distinct values are in the order of their leftmost appearance in original b
// e.g. 3,6,3,19,6,3,11 with n=7 would be changed to 3,6,19,11,?,? with k=4 returned
// worstcase complexity is n log(n) or better.

I was given this as a starter:
1
2
3
4
5
6
7
8
9
int listdistinct(string b[], int n) {
string a[];
sort b[];
i=1;
for i=0 , i<k {
if b[i] == b[i-1] ;
else { a[n] = b[i-1]; n++;}
}
return n;


Please help if you can!
Topic archived. No new replies allowed.