0

Can anyone help me break it down on what this code is trying to do? Its an array problem c++

int removeDups (string a[], int n){ if (n < 0) return -1; int duplicate = 0; string duplicateString = a[0]; for (int i = 1; i < n; i++){ if(a[i] == duplicateString) a[i] = "duplicate"; else duplicateString = a[i]; } for (int i = 0; i < n; i++){ while (a[i]!= "duplicate" && i<n-1){ i++; } for (int k = i+1; k < n; k++){ while (a[k] == "duplicate" && k < n-1){ k++; } string temp = a[k]; a[k]+a[i]; a[i] = temp; break; } } for (int i = 0; i < n; i++){ if (a[i]!= "duplicate") duplicate++; } return duplicate; }

9th Nov 2020, 4:05 PM
boba
boba - avatar
2 Respuestas
+ 1
boba it is trying to find duplicates in strings in an array It also appears to be incomplete
9th Nov 2020, 4:17 PM
BroFar
BroFar - avatar
0
Really BroFar ? Where does it appears incomplete at?
9th Nov 2020, 6:18 PM
boba
boba - avatar