l12.1b

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 1B 代码 · 共 61 行

1B
61
字号
#printThe function getnum actually returns -1 when itencounters end of file. (The source is in getnum.cif you're interested.)Write, compile and run a program thatreads numbers one per line with getnumand, for each, prints:small	if the number is >0 and <=100big	if the number is >100 and <=1000huge	if the number is >1000.Type "ready" when you're done.#once cp %s/getnum.o .#once cp %s/getnum.c .#once #create Ref100110009991011001#once #create Ref1hugebigbigbigsmallsmall#usera.out <Ref >test#cmp Ref1 test#succeed/* One way:*/main() {	int n;	while ((n = getnum()) >= 0)		if (n > 0 && n <= 100)			printf("small\n");		else if (n > 100 && n <= 1000)			printf("big\n");		else if (n > 1000)			printf("huge\n");}/* 	Notice that in principle n could be negative,	so we need the last case to say		else if (n > 1000)	instead of just falling into it with a bare		else	Also it's a good idea to indent the else-if's	exactly the way they are here; otherwise	you'll lose track of what's going on.**/#log#next13.1a 10

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?