first commit!
This commit is contained in:
21
arrays.c
Normal file
21
arrays.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int ch, n_whitesp, n_other;
|
||||
int n_digit[10] = {0}; /* initialize array with zeroes */
|
||||
|
||||
n_whitesp = n_other = 0;
|
||||
|
||||
while ((ch = getchar()) != EOF)
|
||||
if (ch >= '0' && ch <= '9')
|
||||
++n_digit[ch - '0'];
|
||||
else if (ch == ' ' || ch == '\n' || ch == '\t')
|
||||
++n_whitesp;
|
||||
else
|
||||
++n_other;
|
||||
|
||||
printf("digits = ");
|
||||
for (int i = 0; i < 10; ++i)
|
||||
printf(" %d", n_digit[i]);
|
||||
printf(", white space = %d, other = %d\n", n_whitesp, n_other);
|
||||
}
|
Reference in New Issue
Block a user