Exemple #1
0
int check(uint32_t *a, uint32_t *b)
{
    uint32_t tmp[6];
    int i;
    memcpy(tmp, a, sizeof(uint32_t) * 6);
    for(i = 0;i < 5; i++)
    {
        rotate_one(tmp, 6);
        if(SAME(tmp, b)) return 1;
    }
    
    memcpy(tmp, a, sizeof(uint32_t) * 6);
    for(i = 0;i < 5; i++)
    {
        rerotate_one(tmp, 6);
        if(SAME(tmp, b)) return 1;
    }
    return 0;
}
Exemple #2
0
int main(int argc, char** argv)
{
    // Rotate a string using several reverse function

    std::string str("01234567");
    std::cout << "Original:" << str << std::endl;
    
    rotate_zero(str, 2);
    std::cout << "Rotate_zero:" << str << std::endl;
    
    rotate_one(str, 2);
    std::cout << "Rotate_one:" << str << std::endl;
    
    rotate_two(str, 2);
    std::cout << "Rotate_two:" << str << std::endl;
    
    rotate_three(str, 2);
    std::cout << "Rotate_three:" << str << std::endl;
}