1.13
This commit is contained in:
parent
68a7e906b6
commit
ad9e7158da
|
@ -1,32 +1,71 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define MAX_AMOUNT_OF_LENGTHS 256
|
||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
int c, i, nwhite, nother;
|
int c, i, j;
|
||||||
int ndigit[10];
|
int current_length, max_length;
|
||||||
|
int nlengths[MAX_AMOUNT_OF_LENGTHS];
|
||||||
|
|
||||||
nwhite = nother = 0;
|
for (i = 0; i < MAX_AMOUNT_OF_LENGTHS; ++i)
|
||||||
for (i = 0; i < 10; ++i)
|
nlengths[i] = 0;
|
||||||
ndigit[i] = 0;
|
|
||||||
|
|
||||||
while ((c = getchar()) != EOF)
|
current_length = max_length = 0;
|
||||||
if (c >= '0' && c <= '9')
|
while ((c = getchar()) != '\n')
|
||||||
++ndigit[c-'0'];
|
{
|
||||||
else if (c == ' ' || c == '\t')
|
if (c == '\n' || c == ' ' || c == '\t')
|
||||||
++nwhite;
|
|
||||||
else if (c == '\n')
|
|
||||||
{
|
{
|
||||||
++nwhite;
|
++nlengths[current_length];
|
||||||
printf("digits = ");
|
if (current_length > max_length)
|
||||||
for (i = 0; i < 10; ++i)
|
max_length = current_length;
|
||||||
printf(" %d", ndigit[i]);
|
current_length = 0;
|
||||||
printf(", white space = %d, other = %d\n", nwhite, nother);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++nother;
|
{
|
||||||
|
++current_length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printf("digits = ");
|
++nlengths[current_length];
|
||||||
for (i = 0; i < 10; ++i)
|
if (current_length > max_length)
|
||||||
printf(" %d", ndigit[i]);
|
max_length = current_length;
|
||||||
printf(", white space = %d, other = %d\n", nwhite, nother);
|
|
||||||
|
printf("horizonal:\n");
|
||||||
|
for (i = 1; i < MAX_AMOUNT_OF_LENGTHS; ++i)
|
||||||
|
{
|
||||||
|
int counter = nlengths[i];
|
||||||
|
if (counter > 0)
|
||||||
|
{
|
||||||
|
printf("%d: ", i);
|
||||||
|
while (counter > 0)
|
||||||
|
{
|
||||||
|
--counter;
|
||||||
|
printf("*");
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n\nvertical:\n");
|
||||||
|
for (j = max_length; j > 0; --j)
|
||||||
|
{
|
||||||
|
for (i = 1; i < MAX_AMOUNT_OF_LENGTHS; ++i)
|
||||||
|
{
|
||||||
|
if (nlengths[i] > 0)
|
||||||
|
{
|
||||||
|
if (nlengths[i] >= j)
|
||||||
|
printf("*");
|
||||||
|
else
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
for (i = 1; i < MAX_AMOUNT_OF_LENGTHS; ++i)
|
||||||
|
{
|
||||||
|
if (nlengths[i] > 0)
|
||||||
|
printf("%d", i);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue