Code:
#include <stdio.h>
/* cont digits,white space, others */
main()
{
int c, i, nwhite, nother;
int ndigit[10];
nwhite = nother = 0;
for (i = 0; i < 10; ++i) /* Ovaj deo mi nije jasan, */
ndigit[i] = 0; /* i zbog cega je on tu ? */
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);
}
#include <stdio.h>
/* cont digits,white space, others */
main()
{
int c, i, nwhite, nother;
int ndigit[10];
nwhite = nother = 0;
for (i = 0; i < 10; ++i) /* Ovaj deo mi nije jasan, */
ndigit[i] = 0; /* i zbog cega je on tu ? */
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);
}
Hvala unapred.
Pozdrav
s1cK
<kow> "There are 10 types of people in the world... those who understand binary and
those who don't."
<SpaceRain> That's only 2 types of people, kow.
<SpaceRain> STUPID
those who don't."
<SpaceRain> That's only 2 types of people, kow.
<SpaceRain> STUPID