笔试题:Suggest a simple and fast way to multiply the input integer digit by 7。

来源:互联网 发布:阿里云 ecs 建站 教程 编辑:程序博客网 时间:2024/06/06 04:35

翻译:不使用乘法运算,使用简单且快捷的方式实现输入的数字乘以7。

解决方案:

#include "stdio.h"int main(int argc, char **argv ){   int a;   printf("Please Input Your Number:\n");   scanf("%d", &a);   printf("Before Multiplying, the number is:%d\n", a);   int b=( (a<<3)-a );   printf("Caculation Results is:%d.\n", b);}


运行效果:


0 0
原创粉丝点击