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