Problem with sorting
Sep 11, 2015 at 8:37am UTC
Hello guys, i maked a script witch will sort inputtext by my list, so first will sort by A, then by B, but problem is when i sort it by A then B wont work, same if i change code to sort first B then A, then B will be sorted but A not..
problem is string a1 when need to sort second letter it seems like a1 length is 0
Here is what will code do first:
1 2 3
lettersortabv(a1, af1, 'B' );
SortThem('B' );
PrintThem();
then:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
void lettersortabv(string arr[], int &cnt1, char let1) {
int founded = 0;
prezimena = 0;
for (unsigned int araz = 0; araz < str.size(); araz++) {
if (str[araz] == ' ' ) {
if (str[araz + 1] == let1) {
if (prezimena == 0) {
founded = 0;
//cout << "Dodajem +.." << endl;
prezimena++;
continue ;
}
else {
founded = 0;
cnt1++;
//cout << "Dodajem +" << endl;
prezimena++;
continue ;
}
}
else {
founded = 2;
continue ;
}
}
if (founded == 0) {
if (str[araz] == let1) {
//cout << cnt1 << "PRONASO: " << let1 << endl;
founded = 1;
prezimena++;
arr[cnt1] = str[araz];
}
else {
continue ;
}
}
else if (founded == 1) {
arr[cnt1] += str[araz];
}
else {
continue ;
}
}
}
then (This code is too long so i cant paste him):
http://pastebin.com/AHwbFffc
then:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
void PrintThem() {
printlast(aa4);
printlast(ab4);
printlast(av4);
printlast(ag4);
printlast(ad4);
printlast(ađ4);
printlast(ae4);
printlast(až4);
printlast(az4);
printlast(ai4);
printlast(aj4);
printlast(ak4);
printlast(al4);
printlast(alj4);
printlast(am4);
printlast(an4);
printlast(anj4);
printlast(ao4);
printlast(ap4);
printlast(ar4);
printlast(as4);
printlast(at4);
printlast(ać4);
printlast(au4);
printlast(aff4);
printlast(ah4);
printlast(ac4);
printlast(ač4);
printlast(adz4);
printlast(aš4);
}
then:
then:
1 2 3 4 5 6
void ResetAll() {
af1 = 0;
af2 = 0;
af3 = 0;
af4 = 0;
}
and that works perfect, but afther that is going:
1 2 3
lettersortabv(a1, af1, 'A' );
SortThem('B' );
PrintThem();
and its not working
Last edited on Sep 11, 2015 at 8:39am UTC
Sep 11, 2015 at 8:57am UTC
Ahh i fixed it, problem is:
1 2 3 4 5 6
void ResetAll() {
af1 = 0;
af2 = 0;
af3 = 0;
af4 = 0;
}
TO: 1 2 3 4 5 6
void ResetAll() {
af1 = 1;
af2 = 1;
af3 = 1;
af4 = 1;
}
Topic archived. No new replies allowed.