fork download
  1. #include <stdio.h>
  2. #include <memory.h>
  3.  
  4. #define IN 1
  5. #define OUT 0
  6. #define MAX_WORDS 10
  7.  
  8. void main(void){
  9. int c, state;
  10. int current, maxword;
  11. int lenword[MAX_WORDS];
  12.  
  13. memset(lenword, 0, MAX_WORDS);
  14.  
  15. current = maxword = 0;
  16. state = OUT;
  17. while((c = getchar()) != EOF){
  18. if(c == ' ' || c == '\t' || c == '\n'){
  19. if(state == IN){
  20. if(lenword[current] > maxword)
  21. maxword = lenword[current];
  22. current++;
  23. state = OUT;
  24. }
  25. }else{
  26. if(state == OUT)
  27. state = IN;
  28. lenword[current]++;
  29. }
  30. }
  31.  
  32. /*Вывод гистограммы*/
  33. int i, j;
  34. for(i = 0; i < current; i++)
  35. printf("%d ", lenword[i]);
  36. for(i = 0; i < maxword; i++){
  37. for(j = 0; j < current; j++){
  38. if(lenword[j] >= i)
  39. putchar('.');
  40. else
  41. putchar(' ');
  42. }
  43. putchar('\n');
  44. }
  45. return 0;
  46. }
Runtime error #stdin #stdout 0s 2056KB
stdin
a b c def gh i
stdout
1 1 1 -1080528473 -1080520844 ...