1
1
12332112022-02-03 16:21:05
C++ / C#
1233211, 2022-02-03 16:21:05

Is there a site for evaluating an npm module?

Please tell me a site where you can see information about the npm module like bundlephobia.com
only so that it also offers similar packages and compares them. I remember I came across a similar site before, but I can not find something.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Dubrovin, 2016-01-13
@Maqsat

int p10[] = {0, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 1000000000};
int change(int *a, int *b, int k, int l)
{
 int rk, rl;
 if(k <= 0 || k > 9 || l <= 0 || l > 9) return 1;
 rk = ((*a/p10[k])%10);
 rl =  ((*b/p10[l])%10);
 *a = *a - (rk*p10[k]) + (rl*p10[k]);
 *b = *b - (rl*p10[l]) + (rk*p10[l]);
 return 0;
}

только это не перегруженная функция.

M
Maxim Moseychuk, 2016-01-13
@fshp

#include <iostream>

using namespace std;

unsigned power10(unsigned y) {
    unsigned result = 1;
    while(y--)
        result = (result << 3) + (result << 1);
    return result;
}

int sign(int a) {
    if(a < 0)
        return -1;
    else
        return 1;
}

void swap(int& a, int& b, unsigned k, unsigned l) {
    const int multiply_a = power10(k);
    const int multiply_b = power10(l);
    const int digit_a    = sign(a) * (a / multiply_a) % 10;
    const int digit_b    = sign(b) * (b / multiply_b) % 10;
    const int add_a = multiply_a * digit_b - multiply_a * digit_a;
    const int add_b = multiply_b * digit_a - multiply_b * digit_b;

    a = a + sign(a)*add_a;
    b = b + sign(b)*add_b;
}

int main() {
    {
        int a = 12345;
        int b = 98765;
        cout << a << ", " << b << " : ";
        swap(a, b, 1, 4);
        cout << a << ", " << b << endl;
    }
    {
        int a = -12345;
        int b = 98765;
        cout << a << ", " << b << " : ";
        swap(a, b, 1, 4);
        cout << a << ", " << b << endl;
    }
    {
        int a = -12345;
        int b = -98765;
        cout << a << ", " << b << " : ";
        swap(a, b, 1, 4);
        cout << a << ", " << b << endl;
    }
    return 0;
}

A
Alexander Ananiev, 2016-01-13
@SaNNy32

You can convert numbers to char arrays and swap k and l elements.
Then convert the string back to a number.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question