int main(int argc, char **argv) {
    unsigned x = atoi(argv[1]);
    int n = atoi(argv[2]);

    unsigned result = rightrot(x, n);
    printBits(sizeof(result), &result);
}
Exemple #2
0
main()
{
	unsigned x=0xff;
	printf("0x%x\n",x);
	printf("0x%x\n",rightrot(x,2));
	return 0;
}
Exemple #3
0
int main(int argc, char *argv[]) {
  int length = 0;
  char line[MAX_LINE_LENGTH];
  int distance;

  if(argc != 2 || !isnumerical(argv[1])) {
    usage();
    exit(EXIT_FAILURE);

  } else {
    distance = atoi(argv[1]);

  }

  while((length = getline2(line, MAX_LINE_LENGTH)) >= 0) {
    if(isnumerical(line)) {
      printf("%u\n", rightrot(atoi(line), distance));

    } else {
      exit(EXIT_FAILURE);

    }
  }

  exit(EXIT_SUCCESS);
}
Exemple #4
0
main()
{
	int x, n;
	x = 20;
	n = 3;
	printf("rotated  decimal equvalent is %d\n", rightrot(x,n));
}
Exemple #5
0
int main()
{
	int x = 12530;
	printIntBinary(x);
	printIntBinary(rightrot(x, 6));
	return 0;
}
int main(int argc, char *argv[]){
	if (argc < 3){
		printf("Usage: %s <int to rotate> <number of bits to rotate>\n", argv[0]);
		exit(1);
	}
	printf("%u\n", rightrot(atoi(argv[1]), atoi(argv[2])));
	return 0;
}
Exemple #7
0
int main() {
    unsigned rightrot(x, n)
    {
        return ((x & (~0 << n)) >> n) | ((x & (~(~0 << n))) << n);
    }

    printf("%u \n",rightrot(240,3));
}
Exemple #8
0
int main()
{
	int x;
	scanf("%d", &x);
	printf("%d\n", leftrot(x));
	printf("%d\n", rightrot(x));
	system("pause");
	return 0;
}
Exemple #9
0
int main()
{
  char buf[80];
  unsigned x;

  printf("%x\n", rightrot(0x1234abcd, 8));
  // abcd1234
  
}
Exemple #10
0
int main() {
  unsigned int x;
  int n;

  while (scanf("%u %d", &x, &n) == 2) {
    printf("%u\n", rightrot(x, n));
  }

  return 0;
}
int main(void) {
    unsigned x;
    int n;

    x = 0xabcdef;
    n = 8;

    printf("%#x\n", rightrot(x, n));

    return 0;
}
int main() {
  unsigned int x;
  int n;

  printf("Please input a number: ");
  scanf("%u", &x);
  printf("Please input the value of rotated to right: ");
  scanf("%d", &n);
  printf("The number after rotated to right is %u\n", rightrot(x, n));

  return 0;
}
Exemple #13
0
/* Test stuff */
int main() {
    unsigned funbits = 0x01234678;
    printf("0x00000067 = 0x%08x\n"
           "0x01234f78 = 0x%08x\n"
           "0x0123..78 = 0x%08x\n"
           "0x67801234 = 0x%08x\n",
            getbits(funbits, 4, 8),
            setbits(funbits, 8, 4, 0xf),
            invbits(funbits, 8, 8),
            rightrot(funbits, 12)
          );
    return 0;
}
Exemple #14
0
int main(int argc, char const *argv[])
{
	unsigned x;
	printf("x: ");
	scanf("%x", &x);
	int n;
	while(1){
		printf("n: ");
		scanf("%d", &n);
		printf("r: %x\n", rightrot(x, n));
	}
	
	return 0;
}
main()
{
	unsigned x, shift;
	int n;

	printf("\nEnter a number : ");
	scanf("%u", &x);
	printf("\nEnter no of positions to be right shifted : ");
	scanf("%d", &n);
	
	shift = rightrot (x,n);
	
	printf("\nNo. entered by you after right shifted : %u", shift);
	
}
int main(void)
{
	int numb1 = 4; 
	char ch1  = 4; 
	long lon1 = 4; 

	typeof(numb1) numb2;
	rightrot(typeof(numb1), 4, 1, numb2);
//	typeof(ch1) ch2 = rightrot(typeof(ch1), 4, 1);
//	typeof(lon1) lon2 = rightrot(typeof(lon1), 4, 1);

	printf("%d\n", numb2);
//	printf("%c\n", ch2);
//	printf("%ld\n", lon2);

	return 0;
}
Exemple #17
0
int main(int argc, const char * argv[])
{
    int i=0;
    unsigned char x = 1;
    int n = 1;
    unsigned char result;
    
    for (i=0; i<argc; i++)
        printf("argv[%d] = %s\n", i, argv[i]);
    
    result = rightrot(x, n);
    
    printf("sifeof(unsigned) = %lu\n", sizeof(unsigned char));
    
    printf("rightrot(%d,%d) = %u\n", x, n, result);
    
    return 0;
}
Exemple #18
0
int main(){

  unsigned x, y, z;

  x = 109;
  y = 30;
  printf("x =%u,\ty =%u\n", x, y);
  print_2(x, 4);
  print_2(y, 4);
  
  z = setbits(x, 7, 2, y);
  printf("\nsetbits(x, 7, 2, y) =\n");
  print_2(z, 4);

  z = invert(x, 31, 32);
  printf("\ninvert(x, 31, 32) =\n");
  print_2(z, 4);

  z = rightrot(x, 3);
  printf("\nrightrot(x, 3) = \n");
  print_2(z, 4);

  return 0;
}
Exemple #19
0
int main(void)
{
    printf("%u\n", rightrot(122, 3)); // output: 1073741839
    printf("%u\n", rightrot(127, 3)); // output: 3758096399
    return 0;
}
int main(void)
{
	printf("%o",rightrot(074,2));
}
Exemple #21
0
int main(){
	printf("%d\n", rightrot(15, 2));
	return 0;
}
int main(void)
{
    printf("%u",(unsigned)rightrot((unsigned)8,(int)1));

    return 0;
}
int main(void) {
    //printf("%u\n", wordlength());
    printf("%d\n", rightrot(3, 1));
}
Exemple #24
0
int main(){
	clrscr();
	printf("rightrot(5, 1) =%u\n", rightrot(5, 1));
	printf("rightrot(256, 2) =%u\n", rightrot(256, 2));
	return 0;
}