问题描述
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a=4,b=2;
a=b<<a + b>>2;
printf("%d", a);
}
我的尝试:
你好先生,我想知道这一步,如何编译这个程序。
请一步一步解释我。
[]
推荐答案
你好先生,我想知道这一步,如何编译这个程序。
hello sir, i want to know the step,how to compile this program.
你已经链接过的页面为你执行这项工作。
在Linux机器上,例如你可以发出
The page you linked already performs the job for you.
On a Linux box, for instance you could issue
gcc -Wall -o foo foo.c
编译 foo.c
源代码获取可执行文件 foo
。
正如Griff所指出的,根据您的环境(操作系统,编译器等),命令行(或GUI按钮)可能不同:阅读相关文档。
实际程序很简单:
to compile the foo.c
source code obtaining the executable foo
.
As Griff's pointed out, depending on your environment (OS, compiler, etc..) the command line (or the GUI button) maybe different: read the releveant documentation.
The actual program is simple:
int a=4,b=2;
初始化 a
,整数值 4
, b
2
。
initializes a
with integer value 4
, b
with 2
.
a=b<<a + b>>2;
为 a
分配新值。分配的值是 =
运算符右侧的表达式求值结果。为了评估这样的表达式,使用 a
和 b
的当前值,即
Assigns a new value to a
. The value assigned is the result of the expression evaluation on the right side of the =
operator. In order to evaluate such an expression, current values of a
and b
are used, i.e.
a = 2<<4 + 2>>2 = 32 + 0 = 32
(有关班次运营商的信息<<
和>>
,看看 [] 。
(For info about shift operators <<
and >>
, have a look at Bitwise operations in C - Wikipedia[^].
printf("%d", a);
输出 a
的值。
这篇关于编程语言'C'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!