mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
fix: Various LGTM fixes
This commit is contained in:
parent
7393d88811
commit
0356a9cdf3
@ -14,17 +14,17 @@ struct node {
|
|||||||
node *right;
|
node *right;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct queue {
|
struct Queue {
|
||||||
node *t[100];
|
node *t[100];
|
||||||
int front;
|
int front;
|
||||||
int rear;
|
int rear;
|
||||||
};
|
};
|
||||||
|
|
||||||
queue q;
|
Queue queue;
|
||||||
|
|
||||||
void enqueue(node *n) { q.t[q.rear++] = n; }
|
void enqueue(node *n) { queue.t[queue.rear++] = n; }
|
||||||
|
|
||||||
node *dequeue() { return (q.t[q.front++]); }
|
node *dequeue() { return (queue.t[queue.front++]); }
|
||||||
|
|
||||||
void Insert(node *n, int x) {
|
void Insert(node *n, int x) {
|
||||||
if (x < n->val) {
|
if (x < n->val) {
|
||||||
@ -123,8 +123,8 @@ void Post(node *n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
q.front = 0;
|
queue.front = 0;
|
||||||
q.rear = 0;
|
queue.rear = 0;
|
||||||
int value;
|
int value;
|
||||||
int ch;
|
int ch;
|
||||||
node *root = new node;
|
node *root = new node;
|
||||||
|
@ -35,7 +35,7 @@ class stats_computer1 {
|
|||||||
n++;
|
n++;
|
||||||
T tmp = x - K;
|
T tmp = x - K;
|
||||||
Ex += tmp;
|
Ex += tmp;
|
||||||
Ex2 += tmp * tmp;
|
Ex2 += static_cast<double>(tmp) * tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** return sample mean computed till last sample */
|
/** return sample mean computed till last sample */
|
||||||
|
@ -14,7 +14,7 @@ void beadSort(int *a, int len) {
|
|||||||
|
|
||||||
// allocating memory
|
// allocating memory
|
||||||
unsigned char *beads = new unsigned char[max * len];
|
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
|
// mark the beads
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
|
@ -14,7 +14,7 @@ int FindNextGap(int x) {
|
|||||||
return std::max(1, x);
|
return std::max(1, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CombSort(int a[], int l, int r) {
|
void CombSort(int b[], int l, int r) {
|
||||||
// Init gap
|
// Init gap
|
||||||
int gap = n;
|
int gap = n;
|
||||||
|
|
||||||
@ -30,8 +30,8 @@ void CombSort(int a[], int l, int r) {
|
|||||||
|
|
||||||
// Compare all elements with current gap
|
// Compare all elements with current gap
|
||||||
for (int i = l; i <= r - gap; ++i) {
|
for (int i = l; i <= r - gap; ++i) {
|
||||||
if (a[i] > a[i + gap]) {
|
if (b[i] > b[i + gap]) {
|
||||||
std::swap(a[i], a[i + gap]);
|
std::swap(b[i], b[i + gap]);
|
||||||
swapped = true;
|
swapped = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user