l14.1a
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 1A 代码 · 共 39 行
1A
39 行
#printUsing the familar "getnum.o" routinewrite a program that reads numbers one per line and determinesfor each if it is prime. Print "prime"for a prime number and "composite" for a non-prime number.Compile, test, and type "ready".#once #create Ref1003917947#once #create Ref1primecomposite#once cp %s/getnum.o .#usera.out <Ref >x1#cmp x1 Ref1#succeed/* A slow but sure prime-tester */main(){ int p, i, comp; while ((p = getnum()) >= 0) { comp = 0; for (i = 2; i*i <= p; i++) if (p%i == 0) { comp = 1; break; } if (comp) printf("composite\n"); else printf("prime\n"); }}#log#next15.1a 10
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?