Vertical Histogram c++ doesnt works -
MiGu3X - 26.03.2013
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
Respuesta: Vertical Histogram c++ doesnt works -
MiGu3X - 26.03.2013
They are good variable names i do all my c scripts with them. Thx for the reply Rockk <3 <3
Re: Vertical Histogram c++ doesnt works -
OrMisicL - 26.03.2013
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
Respuesta: Vertical Histogram c++ doesnt works -
MiGu3X - 26.03.2013
Duh. Nvm i disnt came her to get blamed. Gonna try fixing it myself.
Re: Vertical Histogram c++ doesnt works -
OrMisicL - 26.03.2013
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 ...)
Re: Vertical Histogram c++ doesnt works -
MiGu3X - 26.03.2013
u man changing variable n to name or WTF? . .
Re: Vertical Histogram c++ doesnt works -
MiGu3X - 26.03.2013
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);;
}
}
}
Re: Vertical Histogram c++ doesnt works -
Jessyy - 26.03.2013
maybe this link will help you ...
http://www.dreamincode.net/forums/to...cal-histogram/
Re: Vertical Histogram c++ doesnt works -
MiGu3X - 26.03.2013
But vertical histograms are possible, but uses tooo much memory and it's difficult to work it out?
Respuesta: Vertical Histogram c++ doesnt works -
MiGu3X - 26.03.2013
Nevermind I fixed it. Thx for help