B语言
(重定向自B语言)
页面Module:Infobox/styles.css没有内容。
| 脚本错误:没有“InfoboxImage”这个模块。 | |
| 脚本错误:没有“InfoboxImage”这个模块。 | |
| 设计者 | 肯·汤普森 |
|---|---|
| 实作者 | 肯·汤普森、丹尼斯·利奇 |
| 发行时间 | 1969年[1] |
| 当前版本 | Template:Software version |
| 型态系统 | 无类型(所有东西都是字) |
| 文件扩展名 | .b |
| 网站 | Template:Official url |
| 受影响于 | |
| BCPL, PL/I, Template:Le | |
| 影响语言 | |
| C语言 | |
脚本错误:没有“Check for unknown parameters”这个模块。
B语言是一种通用的程序设计语言,大约于1969年时,由美国贝尔实验室的电脑科学家肯·汤普森在丹尼斯·利奇的支持下设计。
肯·汤普森最初想在UNIX上开发一个Fortran编译器,但后来引进了BCPL的风格,形成一个新语言即B语言。后来,丹尼斯·利奇以B语言为基础开发出C语言,自从C语言渐渐发展成为目前世界上最常用的程式语言之一之后,B语言几乎已遭弃置。
例子[编辑]
下面是肯·汤普森在《B用户参考》中提供的源代码[2]:
/* The following function will print a non-negative number, n, to
the base b, where 2<=b<=10. This routine uses the fact that
in the ASCII character set, the digits 0 to 9 have sequential
code values. */
printn(n, b) {
extrn putchar;
auto a;
/* Wikipedia note: auto declares a variable with automatic
storage (lifetime is function scope), not "automatic typing"
as in C++11. */
if (a = n / b) /* assignment, not test for equality */
printn(a, b); /* recursive */
putchar(n % b + '0');
}
/* The following program will calculate the constant e-2 to about
4000 decimal digits, and print it 50 characters to the line in
groups of 5 characters. The method is simple output conversion
of the expansion
1/2! + 1/3! + ... = .111....
where the bases of the digits are 2, 3, 4, . . . */
main() {
extrn putchar, n, v;
auto i, c, col, a;
i = col = 0;
while(i<n)
v[i++] = 1;
while(col<2*n) {
a = n+1 ;
c = i = 0;
while (i<n) {
c =+ v[i] *10;
v[i++] = c%a;
c =/ a--;
}
putchar(c+'0');
if(!(++col%5))
putchar(col%50?' ': '*n');
}
putchar('*n*n');
}
v[2000];
n 2000;
参见[编辑]
引用[编辑]
外部链接[编辑]
- The Development of the C Language(页面存档备份,存于互联网档案馆)
- Users' Reference to B,Ken Thompson著
- The Programming Language B
package.lua第80行Lua错误:module 'Module:Arguments' not found Template:肯·汤普逊navbox