|
|
1.1 ! root 1: #print ! 2: Write a program which reads ! 3: its input and counts the number of ! 4: characters and the number of spaces ! 5: (where a space is either a blank or ! 6: a tab or a newline). Print both numbers. ! 7: Compile, test, and type "ready". ! 8: #once #create Ref ! 9: hoboken harrison newark roseville avenue grove street ! 10: east orange brick church orange highland avenue ! 11: mountain station south orange maplewood millburn short hills ! 12: summit chatham madison convent station morristown ! 13: new providence murray hill berkeley heights ! 14: gillette stirling millington lyons basking ridge ! 15: bernardsville far hills peapack gladstone ! 16: #user ! 17: a.out <Ref >x1 ! 18: a.out <Ref >x2 ! 19: grep 348 x1 >/dev/null || grep 45 x2 >/dev/null ! 20: #succeed ! 21: #include <stdio.h> ! 22: /* One way: */ ! 23: ! 24: main() { ! 25: int nchar, nspace; ! 26: char c; ! 27: ! 28: nchar = nspace = 0; ! 29: while ((c = getchar()) != EOF) { ! 30: nchar++; ! 31: if (c == ' ' || c == '\t' || c == '\n') ! 32: nspace++; ! 33: } ! 34: printf("spaces = %d, chars = %d\n", nspace, nchar); ! 35: } ! 36: #log ! 37: #next ! 38: 14.1a 10 ! 39: 14.2a 5
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.