Vertical Histogram c++ doesnt works
#1

Code:

pawn Код:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

//histograma vertical que a cada palabra del input le hace una barrita que cuenta cuбntas letras tiene esa palabra
main()

{
    int i=0, k, l;
    char c, s[30];
   
    for (l=0; l<=30; ++l) {
                    s[l] = '\0';
                }
               
    for (k=0; k<=30; ++k) {
       
        while ((c=getchar())!=EOF) {
           
                if (i==k && c!=' ' && c!='\n') {
                    s[i++]='+';
                }
                else if (i != k && c!=' ') {
                    ++i;
                }
                else if (c==' ') {
                    s[i]=' ', i=0;
                }
            }
            printf("%s\n", s);
    }
}
Help me please. When i press enter it doesnt gives me anything. Thx MiGu3X
Reply
#2

They are good variable names i do all my c scripts with them. Thx for the reply Rockk <3 <3
Reply
#3

The code is really messy, i tried to understand what u're trying to do, but i couldnt figure it out
if u maybe tell us what u're trying to accomplish with that code, we'll be able to help u
Reply
#4

Duh. Nvm i disnt came her to get blamed. Gonna try fixing it myself.
Reply
#5

Nobody blamed u dude, people were simply asking u to clarify ur code (naming variables, give us hints of what u're trying to do ...)
Reply
#6

u man changing variable n to name or WTF? . .
Reply
#7

ok, look, what i want to do is that, when u type like "I saw a kid" to look like this when it prints.

Код:
   +     +
   +     +
+  +  +  +
Each Plus means a letter. The one at the left down corner is the "I" and that way.

By Naming variables u mean chaning s to string ?


maybe i can give u an idea with my horizontal histogram, but i can't work it out with vertical :/

pawn Код:
#include <stdio.h>

main()
{
    char character;
    while ((character = getchar()))
    {
        if(character != ' ')
        {
            printf("+");
        }
        else if(character == ' ')
        {
            printf("%c\n", character);;
        }
    }
}
Reply
#8

maybe this link will help you ... http://www.dreamincode.net/forums/to...cal-histogram/
Reply
#9

But vertical histograms are possible, but uses tooo much memory and it's difficult to work it out?
Reply
#10

Nevermind I fixed it. Thx for help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)