zoukankan      html  css  js  c++  java
  • c语言 7-3

    1、

    #include <stdio.h>
    
    unsigned rrotate(unsigned x, int n)
    {
        return x >> n;
    }
    
    unsigned lrotate(unsigned x, int n)
    {
        return x << n;
    }
    
    int main(void)
    {
        unsigned x; int n;
        puts("please input the test number and move bits.");
        printf("x = "); scanf("%u", &x);
        printf("n = "); scanf("%u", &n);
        
        printf("right : %u  | left : %u
    ", rrotate(x, n), lrotate(x, n));
        
        return 0;
    }

    2、

    #include <stdio.h>
    
    unsigned rrotate(unsigned x, int n)
    {
        return x >> n;
    }
    
    unsigned lrotate(unsigned x, int n)
    {
        return x << n;
    }
    
    int main(void)
    {
        unsigned x; int n;
        puts("please input the test number and move bits.");
        printf("x = "); scanf("%u", &x);
        printf("n = "); scanf("%d", &n);
        
        int i;
        for(;;)
        {
            puts("choose:  1 →right;2 →left");
            printf("i = "); scanf("%d", &i);
            if(i == 1 | i == 2)
                break;
            puts("input error, 1 or 2 ?"); 
        }
        
        if(i == 1)
            printf("right: %u
    ", rrotate(x, n));
        else
            printf("left : %u
    ", lrotate(x, n));
            
        return 0;
    }

    3、

    #include <stdio.h>
    
    unsigned rrotate(unsigned x, int n)
    {
        return x >> n;
    }
    
    unsigned lrotate(unsigned x, int n)
    {
        return x << n;
    }
    
    int main(void)
    {
        unsigned x; int n;
        puts("please input the test number and move bits.");
        printf("x = "); scanf("%u", &x);
        printf("n = "); scanf("%d", &n);
        
        int i;
        while(!0)
        {
            puts("choose: 1 →right; 2 →left");
            printf("i = "); scanf("%d", &i);
            
            if(i == 1 || i == 2)
                break;
            puts("input error! 1 or 2 ?");
        } 
        
        if(i == 1)
            printf("right: %u
    ", rrotate(x, n));
        else
            printf("left : %u
    ", lrotate(x, n));
        
        return 0;
    }

    4、

    #include <stdio.h>
    
    unsigned rrotate(unsigned x, int n)
    {
        return x >> n;
    }
    
    unsigned lrotate(unsigned x, int n)
    {
        return x << n;
    }
    
    int main(void)
    {
        unsigned x; int n;
        puts("please input the test number and move bits.");
        printf("x = "); scanf("%u", &x);
        printf("n = "); scanf("%d", &n);
        
        int i;
        do
        {
            puts("choose i: 1 →right; 2 →left");
            printf("i = "); scanf("%d", &i);
            if(i < 1 || i > 2)
                puts("input error! 1 or 2 ?");
        }
        while(i < 1 || i > 2);
        
        if(i == 1)
            printf("right: %u
    ", rrotate(x, n));
        else
            printf("left : %u
    ", lrotate(x, n));
            
        return 0;
    }

  • 相关阅读:
    vue项目锚点定位+滚动定位
    elementUI 弹出框添加可自定义拖拽和拉伸功能,并处理边界问题
    密码检验规则(字母数字和特殊字符组成的混合体)
    分布式版本控制系统git
    自动生成滚动条
    jq中append(),appendTo(),after(),before(),prepend(),prependTo()的用法
    清除浮动的几种方式
    王者荣耀周年福利活动绕过微信屏蔽
    看不懂源码?先来恶补一波Object原型吧
    Vue组件化开发
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14792973.html
Copyright © 2011-2022 走看看