mirror of
https://github.com/krislamo/knrc.git
synced 2025-01-07 03:50:36 +00:00
Exercise 1-13. Vertical histogram
This commit is contained in:
parent
04ac11bea1
commit
f232d42ece
@ -6,11 +6,10 @@
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
int c, i, j, state, count, top;
|
||||||
int c, i, j, state, count;
|
|
||||||
int wordl[100];
|
int wordl[100];
|
||||||
|
|
||||||
count = state = OUT;
|
count = state = top = OUT;
|
||||||
for(i = 0; i < 100; ++i)
|
for(i = 0; i < 100; ++i)
|
||||||
wordl[i] = 0;
|
wordl[i] = 0;
|
||||||
|
|
||||||
@ -34,13 +33,23 @@ int main()
|
|||||||
else if (count >= 100)
|
else if (count >= 100)
|
||||||
printf(MAXERROR, count);
|
printf(MAXERROR, count);
|
||||||
|
|
||||||
|
for (i = 0; i < 100; ++i)
|
||||||
|
if (wordl[i] > top)
|
||||||
|
top = wordl[i];
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
for (i = 0; i < 100; ++i) {
|
for (i = 0; i < 100; ++i)
|
||||||
if (wordl[i] > 0) {
|
if (wordl[i] > 0)
|
||||||
printf("%2d | ", i);
|
printf("%2d ", i);
|
||||||
for (j = 0; j < wordl[i]; ++j)
|
|
||||||
printf("#");
|
printf("\n");
|
||||||
printf("\n");
|
for (i = 1; i <= top; ++i) {
|
||||||
|
for (j = 0; j < 100; ++j) {
|
||||||
|
if (wordl[j] >= i)
|
||||||
|
printf(" # ");
|
||||||
|
else if (wordl[j] > 0)
|
||||||
|
printf(" ");
|
||||||
}
|
}
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user