Exemplo n.º 1
0
Arquivo: xs.c Projeto: npe9/harvey
void
rright(void)
{
    if(canfit(rotr(piece))) {
        setpiece(rotr(piece));
        drawpiece();
        flushimage(display, 1);
    }
}
Exemplo n.º 2
0
Node *rebalance(Node *x) {
    x->u();
    if (x->l->h > 1 + x->r->h){
        if (x->l->l->h < x->l->r->h) x->l = rotl(x->l);
        x = rotr(x);
    }
    else if (x->r->h > 1 + x->l->h){
        if (x->r->r->h < x->r->l->h) x->r = rotr(x->r);
        x = rotl(x);    
    }
    return x;
}
Exemplo n.º 3
0
void Encrypt(uint8_t *block, uint8_t *roundKeys)
{
	uint32_t* blk = (uint32_t*) block;
	uint32_t* rk = (uint32_t*) roundKeys;
	int8_t i;
	
	for (i = 0; i < NUMBER_OF_ROUNDS; i += 4, rk += 4) {
		blk[3] = rotr((blk[2] ^ RK(rk, 3)) + (blk[3] ^ RK(rk, 1)), 3);
		blk[2] = rotr((blk[1] ^ RK(rk, 2)) + (blk[2] ^ RK(rk, 1)), 5);
		blk[1] = rotl((blk[0] ^ RK(rk, 0)) + (blk[1] ^ RK(rk, 1)), 9);
		
		rk += 4;
		blk[0] = rotr((blk[3] ^ RK(rk, 3)) + (blk[0] ^ RK(rk, 1)), 3);
		blk[3] = rotr((blk[2] ^ RK(rk, 2)) + (blk[3] ^ RK(rk, 1)), 5);
		blk[2] = rotl((blk[1] ^ RK(rk, 0)) + (blk[2] ^ RK(rk, 1)), 9);
		
		rk += 4;
		blk[1] = rotr((blk[0] ^ RK(rk, 3)) + (blk[1] ^ RK(rk, 1)), 3);
		blk[0] = rotr((blk[3] ^ RK(rk, 2)) + (blk[0] ^ RK(rk, 1)), 5);
		blk[3] = rotl((blk[2] ^ RK(rk, 0)) + (blk[3] ^ RK(rk, 1)), 9);
		
		rk += 4;
		blk[2] = rotr((blk[1] ^ RK(rk, 3)) + (blk[2] ^ RK(rk, 1)), 3);
		blk[1] = rotr((blk[0] ^ RK(rk, 2)) + (blk[1] ^ RK(rk, 1)), 5);
		blk[0] = rotl((blk[3] ^ RK(rk, 0)) + (blk[0] ^ RK(rk, 1)), 9);
	}
}
Exemplo n.º 4
0
static struct node* balance(struct node* n) {
  int d = delta(n);

  if (d < -1) {
    if (delta(n->right) > 0)
      n->right = rotr(n->right);
    return rotl(n);
  } else if (d > 1) {
    if (delta(n->left) < 0)
      n->left = rotl(n->left);
    return rotr(n);
  }
  updateheight(n);
  return n;
}
Exemplo n.º 5
0
int main()
{
    int  spins,i,l,m,*ptr,*ptr2,*ptr3;
    printf("Vuvedi chislo\n");
    scanf("%d",&i);

    printf("Vuvedi chislo\n");
    scanf("%d",&l);

    printf("Vuvedi chislo\n");
    scanf("%d",&m);

    printf("Times to spin");
    scanf("%d",&spins);

    ptr=&i;
    ptr2=&l;
    ptr3=&m;

    while(1 <= spins)
        {
            rotr(ptr,ptr2,ptr3);
            spins--;
        }
    printf("1=%x\n2=%d\n3=%d",*ptr,*ptr2,*ptr3);
    return 0;
}
Exemplo n.º 6
0
int main() {
    int a, b ,c ;
    rotr(&a, &b , &c);
    printf("%d%d%d",a,b,c);

    return (0);
}
Exemplo n.º 7
0
int main()
{   int n;
    cout << " Input number of basic points: ";
    cin >> n;
    Extpair p(0,100),shp(280,330);
    bpoint bp(0,0,.5,0,0,.5);
    matrix rotr(cos(2*PI/n),-sin(2*PI/n),sin(2*PI/n),cos(2*PI/n));
    int psize=n;
    fractal f,g;
    (f.basicpoints).clear();
    (g.basicpoints).clear();
    for(int i=0; i<psize; i++)
    {   bp.point=p+shp;
        (f.basicpoints).push_back(bp);
        p=rotr.MultRow(p);
    }
    //vector< vector<bpoint> > memofr;
    //memofr.clear();
    f.build(10);
    vector<fractal> input;
    input.push_back(f);
    input.push_back(f);
    input.push_back(f);
    input.push_back(f);
//printtops_out(input,.000001);
    f.writetops(.000001);
    //f.writetops_int(.000001);
}
Exemplo n.º 8
0
Node *rebalance(Node *x) {
	x->u();
	if (x->l->h > 1 + x->r->h) {
		12
		if (x->l->l->h < x->l->r->h) x->l = rotl(x->l);
		x = rotr(x);
	} else if (x->r->h > 1 + x->l->h) {
Exemplo n.º 9
0
int main (){
int a, b, c, n;
scanf("%d  %d  %d  %d", &a, &b, &c, &n);
rotr(&a, &b, &c, n);
printf(" %d  %d  %d ", a, b, c);
return 0;
}
Exemplo n.º 10
0
int main() {
    int a, b, c, rotate_times;
    scanf( "%d %d %d %d" , &a , &b , &c , &rotate_times );
    for ( ; rotate_times > 0 ; rotate_times-- ) {
        rotr( &a , &b , &c );
    }
    printf("%d %d %d", a , b , c);
    return 0;
}
Exemplo n.º 11
0
static unsigned int get_immed_operand_for_data_proc_instr(unsigned int instr)
{
	u8 immed_8, rotate_imm;

	immed_8 = instr & 0xff;
	rotate_imm = instr & 0xf00;

	return rotr(immed_8, 2 * rotate_imm, 8);
}
Exemplo n.º 12
0
int main()
{
    int a,b,c,n,i;
    scanf("%d %d %d %d" ,&a,&b,&c,&n);
    for(i=0;i<n;i++)
        rotr(&a,&b,&c);
    printf("%d %d %d",a,b,c);
        return 0;
}
Exemplo n.º 13
0
static void unscramble_block(struct piscine *pisc, uint32_t swap_seed)
{
	swap_seed = rotl(swap_seed, 16);
	uint8_t i = 16;
	do {
		i--;
		swap_seed = rotr(swap_seed, 3);
		swap_quadrupel(pisc->w_buf, i, ((~i) ^ swap_seed) & 0xF);
	} while (i != 0);
}
Exemplo n.º 14
0
int main(){
	int a, b, c, i;
		scanf("%d %d %d %d", &a, &b, &c, &i);
	while(i >=0) {
		rotr(&a, &b, &c);
		printf("%d %d %d\n", a, b ,c);
		i--;
		return 0;
	}
}
Exemplo n.º 15
0
int main() {
    int a, b, c, n;
    scanf("%d%d%d%d",&a,&b,&c,&n);

    while(n-- != 0) {
        rotr(&a,&b,&c);
    }

    printf("%d %d %d",a,b,c);

    return 0;
}
Exemplo n.º 16
0
int main() {
    int a , b , c , linuxcantcompilesimple30liner ;
        scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &linuxcantcompilesimple30liner);
	
    rotr(&a, &b , &c , linuxcantcompilesimple30liner);
    printf("%d %d %d", a , b , c);

    return 0;
}
Exemplo n.º 17
0
bool Rotl :: execute () {
    bool changed = false;
    unsigned int mask;
    Word tmp;

    tmp = Word(rotl(this->source->g_word(), this->bits),
               rotl(this->source->g_mask(), this->bits));
    mask = this->result->g_mask();
    this->result->take_bits(tmp);
    if (mask != this->result->g_mask())
        changed = true;


    tmp = Word(rotr(this->result->g_word(), this->bits),
               rotr(this->result->g_mask(), this->bits));
    mask = this->source->g_mask();
    this->source->take_bits(tmp);
    if (mask != this->source->g_mask())
        changed = true;

    return changed;
}
Exemplo n.º 18
0
int main(){
	int times_swap;
	int count;
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&times_swap);
	for(count = 0; count < times_swap; count++){
			rotr(&a,&b,&c);	
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}
Exemplo n.º 19
0
int main()
{
    int i,n,a,b,c;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        rotr(&a,&b,&c);
    }
    printf("%d %d %d",a,b,c);
    return 0;
}
Exemplo n.º 20
0
int main()
{
    int a,b,c,n;
    scanf("%d %d %d %d",&a,&b,&c,&n);
    while (n>0)
    {
        n--;
        rotr(&a,&b,&c);
    }
    printf("%d ",a);
    printf("%d ",b);
    printf("%d",c);
    return 0;
}
Exemplo n.º 21
0
Arquivo: p.c Projeto: DavidToca/acm
void insert(int k)
{
	int x;

	if (root == 0) {
		left[0] = right[0] = parent[0] = height[0] = key[0] = count[0] = 0;
		left[1] = right[1] = parent[1] = 0;
		count[1] = height[1] = total = root = 1;
		key[1] = k;
		return;
	}

	for (total++, x = root;;) {
		if (k < key[x]) {
			if (left[x] == 0) {
				left[x] = total;
				break;
			}
			x = left[x];
		} else if (k > key[x]) {
			if (right[x] == 0) {
				right[x] = total;
				break;
			}
			x = right[x];
		} else {
			for (; x != 0; x = parent[x])
				count[x]++;
			return;
		}
	}

	parent[total] = x;
	x = total;
	key[x] = k;
	left[x] = 0;
	right[x] = 0;
	count[x] = 1;
	height[x] = 1;

	for (x = parent[x]; x != 0; x = parent[x]) {
		count[x]++;
		height[x] = max(height[left[x]], height[right[x]]) + 1;

		if (height[left[x]] < (height[right[x]] - 1))
			x = rotl(x);
		else if (height[right[x]] < (height[left[x]] - 1))
			x = rotr(x);
	}
}
Exemplo n.º 22
0
void Decrypt(uint8_t *block, uint8_t *roundKeys)
{
	uint32_t* blk = (uint32_t*) block;
	uint32_t* rk = (uint32_t*) roundKeys;
	int8_t i;
	
	uint32_t b0 = blk[0];
	uint32_t b1 = blk[1];
	uint32_t b2 = blk[2];
	uint32_t b3 = blk[3];
	
	for (i = NUMBER_OF_ROUNDS - 1, rk += 92; i >= 0; i -= 4, rk -= 4) {
		b0 = (rotr(b0, 9) - (b3 ^ RK(rk, 0))) ^ RK(rk, 1);
		b1 = (rotl(b1, 5) - (b0 ^ RK(rk, 2))) ^ RK(rk, 1);
		b2 = (rotl(b2, 3) - (b1 ^ RK(rk, 3))) ^ RK(rk, 1);
				
		rk -= 4;
		b3 = (rotr(b3, 9) - (b2 ^ RK(rk, 0))) ^ RK(rk, 1);
		b0 = (rotl(b0, 5) - (b3 ^ RK(rk, 2))) ^ RK(rk, 1);
		b1 = (rotl(b1, 3) - (b0 ^ RK(rk, 3))) ^ RK(rk, 1);
		
		rk -= 4;
		b2 = (rotr(b2, 9) - (b1 ^ RK(rk, 0))) ^ RK(rk, 1);
		b3 = (rotl(b3, 5) - (b2 ^ RK(rk, 2))) ^ RK(rk, 1);
		b0 = (rotl(b0, 3) - (b3 ^ RK(rk, 3))) ^ RK(rk, 1);
		
		rk -= 4;
		b1 = (rotr(b1, 9) - (b0 ^ RK(rk, 0))) ^ RK(rk, 1);
		b2 = (rotl(b2, 5) - (b1 ^ RK(rk, 2))) ^ RK(rk, 1);
		b3 = (rotl(b3, 3) - (b2 ^ RK(rk, 3))) ^ RK(rk, 1);
	}
	
	blk[0] = b0;
	blk[1] = b1;
	blk[2] = b2;
	blk[3] = b3;
}
Exemplo n.º 23
0
int main()
{
	int a,b,c,n;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&n);
	while(n>0){
		rotr(&a,&b,&c);
		n--;
	}
	printf("\n %d %d %d",a,b,c);
	
	return 0;
}
Exemplo n.º 24
0
int main()
{
    int e,f,g;

    scanf("%d",&e);
    scanf("%d",&f);
    scanf("%d",&g);

    rotr(&e,&f,&g);
    printf("%d ",e);
    printf("%d ",f);
    printf("%d ",g);

    return 0;
}
Exemplo n.º 25
0
int main()
{
    int a, b, c, times, i = 0;
    scanf ("%d", &a);
    scanf ("%d", &b);
    scanf ("%d", &c);
    scanf ("%d", &times);
    do
    {
        rotr (&a, &b, &c);
        i++;
    }while (i<times);
    printf ("\n%d %d %d", a, b, c);
    return 0;
}
Exemplo n.º 26
0
int main()
{
	int a, b, c;
	int n;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&n);
	for ( ; n>0; n--)
	{
		rotr (&a, &b, &c);
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}
Exemplo n.º 27
0
int main(){
        
    int a, b, c, n, count;
    printf("Enter numbers and number of rotations\n");
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &n);
    for(count=0; count<n; count++){
        rotr(&a, &b, &c);
    }
    printf("\n %d %d %d \n", a, b, c);    
    
    
    return 0;
}
Exemplo n.º 28
0
int main(void)
{
    int a, b, c, n;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &n);
    while(n!=0)
    {
        rotr(&a, &b, &c);
        n--;
    }
    printf("%d ", a);
    printf("%d ", b);
    printf("%d ", c);
    return 0;
}
Exemplo n.º 29
0
int main()
{
	int a, b, c, n, i;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &n);

	for(i = 0; i < n; i++)
	{
		rotr(&a, &b, &c);
	}

	printf("%d ", a);
	printf("%d ", b);
	printf("%d\n", c);

	return 0;
}
Exemplo n.º 30
0
int main()
{
	int a,b,c,counter;
	int times;

	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);

	scanf("%d",&times);

	for (counter = 0; counter < times; counter++)
	{
		rotr(&a,&b,&c);
	}

	printf("%d %d %d", a, b, c);

	return 0;
}