about summary refs log tree commit diff stats
path: root/1.6.c
diff options
context:
space:
mode:
Diffstat (limited to '1.6.c')
-rw-r--r--1.6.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/1.6.c b/1.6.c
new file mode 100644
index 0000000..4ed1550
--- /dev/null
+++ b/1.6.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+
+int main () {
+	int c, i, nwhite, nother;
+	int ndigit[10] = {0};
+	nwhite = nother = 0;
+
+	while ((c = getchar()) != EOF)
+		if (c >= '0' && c <= '9')
+			++ndigit[c-'0'];
+		else if (c == ' ' || c == '\n' || c == '\t')
+			++nwhite;
+		else
+			++nother;
+	printf("digits =");
+	for (i = 0; i < 10; ++i)
+		printf(" %d", ndigit[i]);
+	printf(". white space = %d, other = %d\n",
+			nwhite, nother);
+}