The following code will count how many times a character appears in entered input. And create a histogram to detail it. I thought it was some pretty cool code, so I decided to share.
[code=c]#include <stdio.h>
#define EOL '\n'
#define ARYLEN 256 /* Length of Ascii Alphabet.. From 0 */
main(){
int c, i, x;
int length[ARYLEN];
for(x = 0; x < ARYLEN;x++)
length[x] = 0;
while( (c = getchar() ) != EOL){
length[c]++;
if (c == EOL)
break;
}
for(x = 0; x < ARYLEN; x++){
if( length[x] > 0){
printf("%c | ", x);
for(i = 1; i <= length[x]; ++i){
printf("*");
}
printf("\n");
}
}
}[/code]
;7$=v?%v%#5>v7v8994
The decrypt code is V, I could not make it any simpler!
(11-01-2011, 09:57 AM)Drumm Wrote: The following code will count how many times a character appears in entered input. And create a histogram to detail it. I thought it was some pretty cool code, so I decided to share.
[code=c]#include <stdio.h>
#define EOL '\n'
#define ARYLEN 256 /* Length of Ascii Alphabet.. From 0 */
main(){
int c, i, x;
int length[ARYLEN];
for(x = 0; x < ARYLEN;x++)
length[x] = 0;
while( (c = getchar() ) != EOL){
length[c]++;
if (c == EOL)
break;
}
for(x = 0; x < ARYLEN; x++){
if( length[x] > 0){
printf("%c | ", x);
for(i = 1; i <= length[x]; ++i){
printf("*");
}
printf("\n");
}
}
}[/code]
Should have included a screen shot!
Having long hair is great until you have to pull a footlong out of the dog's butt. flatank.blogspot.com
I. AM. LATCH.
Dude you need to change the default settings on your terminal, like turn off that shit transparency and change the color to something less purplish. The code is good though, keep it up.
Trolls are the last thing you need to be concerned with.
VCD Wrote:// Forever more, count and reply, bitch.
The transparency isn't bothering me- I just wanted to SEE what he was doing. Thanks Drumm. I like writing things like this for my own amusement, too. If you write a sentence, the space always has the longest set of asterisks on the top there.
Having long hair is great until you have to pull a footlong out of the dog's butt. flatank.blogspot.com
I. AM. LATCH.
Whether it is bothering you has no relevance. I am the one leading DM down the path of light, and if I ever see ask him for a screenshot I would prefer something less fruity in the color coordination. Thanks anyway latch.
Trolls are the last thing you need to be concerned with.
VCD Wrote:// Forever more, count and reply, bitch.
(14-01-2011, 06:07 AM)Pack3t SynAck3r Wrote: Whether it is bothering you has no relevance. I am the one leading DM down the path of light, and if I ever see ask him for a screenshot I would prefer something less fruity in the color coordination. Thanks anyway latch.
You didn't ask for a screenshot! I did and I didn't care if it was fruity, but if that gets in your way of mentoring, I'll step aside.
Having long hair is great until you have to pull a footlong out of the dog's butt. flatank.blogspot.com
I. AM. LATCH.
SHARN wrote copy, pasted a macbuntu theme. Do it!