Datei: p3-11.c


    1   /*
    2    *      p3-11.c
    3    *      Beispielprogramm 11, Abschnitt 3
    4    *      Ziffern, Zwischenraeume und andere Zeichen zaehlen
    5    */
    6   
    7   #include <stdio.h>
    8   
    9   void main(void)
   10   {
   11     int c, i, nwhite, nother;
   12     int ndigit[10];
   13     
   14     nwhite = nother = 0;
   15     
   16     for (i=0; i<10; ++i)
   17       ndigit[i]=0;
   18       
   19     while ((c = getchar()) != EOF)
   20       if (c >= '0' && c <= '9')
   21         ++ndigit[c-'0'];
   22       else if (c == ' ' || c == '\n' || c == '\t')
   23         ++nwhite;
   24       else
   25         ++nother;
   26         
   27     printf("Zahlen =");
   28     for (i=0; i<10; ++i)
   29       printf(" %d", ndigit[i]);
   30     printf("\n\"White Space\" = %d, andere = %d\n", nwhite, nother);
   31   
   32   } /* main() */


Erzeugt von c2html 1.01