mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-02 10:12:45 +08:00
fix: Various LGTM fixes
This commit is contained in:
@@ -14,7 +14,7 @@ void beadSort(int *a, int len) {
|
||||
|
||||
// allocating memory
|
||||
unsigned char *beads = new unsigned char[max * len];
|
||||
memset(beads, 0, max * len);
|
||||
memset(beads, 0, static_cast<size_t>(max) * len);
|
||||
|
||||
// mark the beads
|
||||
for (int i = 0; i < len; i++)
|
||||
|
||||
@@ -14,7 +14,7 @@ int FindNextGap(int x) {
|
||||
return std::max(1, x);
|
||||
}
|
||||
|
||||
void CombSort(int a[], int l, int r) {
|
||||
void CombSort(int b[], int l, int r) {
|
||||
// Init gap
|
||||
int gap = n;
|
||||
|
||||
@@ -30,8 +30,8 @@ void CombSort(int a[], int l, int r) {
|
||||
|
||||
// Compare all elements with current gap
|
||||
for (int i = l; i <= r - gap; ++i) {
|
||||
if (a[i] > a[i + gap]) {
|
||||
std::swap(a[i], a[i + gap]);
|
||||
if (b[i] > b[i + gap]) {
|
||||
std::swap(b[i], b[i + gap]);
|
||||
swapped = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user